Subject: send_existing does not clear the flag LIBSSH2_SESSION_BLOCK_OUTBOUND

send_existing does not clear the flag LIBSSH2_SESSION_BLOCK_OUTBOUND

From: Sebastien Fricker <Sebastien.Fricker_at_ipetronik.com>
Date: Fri, 26 Mar 2010 18:33:26 +0100

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

Here the source original source code:
transport.c line 646:
(http://git.libssh2.org/?p=libssh2.git;a=blob;f=src/transport.c;h=43df76c13c3f560040961898115b8e6e6bfd382d;hb=HEAD#l648)
 646 if (rc == length) {
 647 /* the remainder of the package was sent */
 648 LIBSSH2_FREE(session, p->outbuf);
 649 p->outbuf = NULL;
 650 p->ototal_num = 0;
 651 }

We should modify it as follows:

 646 if (rc == length) {
 647 /* the remainder of the package was sent */
             session->socket_block_directions &=
~LIBSSH2_SESSION_BLOCK_OUTBOUND;
 648 LIBSSH2_FREE(session, p->outbuf);
 649 p->outbuf = NULL;
 650 p->ototal_num = 0;
 651 }

This avoids that libssh2 uses 100% CPU, when an outgoing transfer to a
server is finished and when libssh is waiting for the answer from
server.

Please feel free to comment this modification.
Regards
S├ębastien
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-03-26