Subject: Re: Re: send/recv callbacks (was Re: writing to channel limited to 2 Mb?)

Re: Re: send/recv callbacks (was Re: writing to channel limited to 2 Mb?)

From: Henrik Nordström <henrik_at_henriknordstrom.net>
Date: Tue, 16 Aug 2011 15:32:17 +0200

tis 2011-08-16 klockan 10:10 +0200 skrev Przemysław Szczygielski:

> It gets a bit tricky with i.e. ssh tunnels. Let's take -L (TCP_channel
> <-> SSH_channel). In big simplification:
>
> TCP_channel's readyRead signal is connected to
> SSH_channel.write(TCP_channel.read())
>
> SSH_channel's readyRead signal is connected to
> TCP_channel.write(SSH_channel.read())

Ah.. SSH do not have such 1-1 mapping of read/write. You need to check
both directions when there is any readyness and use
libssh2_session_blocking_direction to tell if libssh2 is waiting for
read or write readiness of the underlying socket.

> This works well until SSH_channel writes only part of the read data
> (meaning that next write will cause EAGAIN). I have to store unwritten
> data somewhere, wait for EAGAIN to clear and write it to SSH channel.
> I am not sure how EAGAIN is cleared but it seems that some traffic on
> "main" SSH channel triggers QxtSshChannelPrivate::d_readyRead:

The EAGAIN condiditons is evaluated each time you try to write to the
channel. When you get EAGAIN you wait for the kind of socket event
indicated by libssh2_session_blocking_direction() and then try the exact
same write again.

when the write is successful (positive response) you advance your write
position by the amount returned and then try to write the remainder.

Regards
Henrik

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