Subject: Re: send_existing does not clear the flag LIBSSH2_SESSION_BLOCK_OUTBOUND

Re: send_existing does not clear the flag LIBSSH2_SESSION_BLOCK_OUTBOUND

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 27 Mar 2010 23:27:47 +0100 (CET)

On Fri, 26 Mar 2010, Sebastien Fricker wrote:

> when send_existing() has fully transferred the remaining outgoing data, the
> flag LIBSSH2_SESSION_BLOCK_OUTBOUND should be clear.

Hm, yes. I agree and that's why the code originally did that!

However, it seems there was some problem with that approach and the commit
7317edab61d2179febc38a2c2c4da0b951d74cbc by Peter Stuge changed that behavior.

I'm trying to read the commit message and think through the code to understand
why that change was made, but I can't quite get it.

My analysis is instead that send_existing() should set the
LIBSSH2_SESSION_BLOCK_OUTBOUND bit for the case when only a piece of the
buffer was sent and it returns PACKET_EAGAIN - in the last line of the
function. As otherwise, it will return EAGAIN without a direction bitmask set
and that's not good.

It signals to the caller that it wants to be called again and it sets for what
direction it wants the socket to be ready to get called.

Comments anyone?

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-03-27