From 7317edab61d2179febc38a2c2c4da0b951d74cbc Mon Sep 17 00:00:00 2001 From: Peter Stuge Date: Wed, 25 Nov 2009 04:52:15 +0100 Subject: [PATCH] Don't always clear write direction blocking flag When libssh2_transport_write() is called to continue sending a partially sent packet the write direction flag must not be cleared until the previous packet has been completely sent, or the app would hang if the packet still isn't sent completely, since select() gets called by the internal blocking emulation layer in libssh2 but would then not be watching the socket for writability. Clear the flag only once processing of previous packet data is complete and a new packet is about to be prepared. --- src/transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/transport.c b/src/transport.c index d9a38ca..cba1bc5 100644 --- a/src/transport.c +++ b/src/transport.c @@ -671,15 +671,15 @@ _libssh2_transport_write(LIBSSH2_SESSION * session, unsigned char *data, debugdump(session, "libssh2_transport_write plain", data, data_len); - /* default clear the bit */ - session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_OUTBOUND; - /* FIRST, check if we have a pending write to complete */ rc = send_existing(session, data, data_len, &ret); if (rc || ret) { return rc; } + /* default clear the bit */ + session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_OUTBOUND; + encrypted = (session->state & LIBSSH2_STATE_NEWKEYS) ? 1 : 0; /* check if we should compress */