Subject: Re: writing to channel limited to 2 Mb?

Re: writing to channel limited to 2 Mb?

From: Przemysław Szczygielski <qus123_at_gmail.com>
Date: Thu, 11 Aug 2011 10:51:09 +0200

>
> Are you using the API in a blocking or non-blocking way?
>
> Non-blocking.

>
> If non-blocking: your code should already be prepared to handle EAGAIN and
> act accordingly when that happens => call libssh2_session_block_**directions()
> to see what to wait for, then wait and then call libssh2 again when things
> happen.
>
>
Well, it isn't exactly my code, as it is part of a library that is a wrapper
to libssh2:

qint64 QxtSshChannel::writeData(const char* buff, qint64 len){

    ssize_t ret=libssh2_channel_write_ex(d->d_channel,
d->d_write_stream_id,buff, len);

    if(ret<0){

        if(ret==LIBSSH2_ERROR_EAGAIN){

            return 0;

        }else{

#ifdef QXT_DEBUG_SSH

            qDebug()<<"write err"<<ret;

#endif

            return -1;

        }

    }

    if (len!=ret)

    {

        qDebug()<<QString("QxtSshChannel::writeData
******KRYTYCZNY!!!! do SSH zapisalo mniej niz dostalo!!!
(%1/%2)").arg(ret).arg(len);

    }

    return ret;

}

So instead of "return 0" I should call libssh2_session_block_directions()
and wait until either read or write to channel is available, depending on
block_directions result?

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-08-11