#258: [PATCH] client spins on write when window full --------------------+-------------------- Reporter: ncm | Owner: Type: defect | Status: new Priority: normal | Milestone: 1.4.3 Component: misc | Version: 1.4.2 Keywords: | Blocked By: Blocks: | --------------------+-------------------- I see CPU go to 100% on writes when the receiver is slow or slow to deliver window adjustments. When the window appears to be full, it seems a grave error to sleep on writability of a socket that is writable all the time.
Suggesting this to reduce sender CPU load without reducing throughput: {{{ --- a/src/channel.c +++ b/src/channel.c @@ -2012,9 +2012,17 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id, if((rc < 0) && (rc != LIBSSH2_ERROR_EAGAIN)) return rc; - if(channel->local.window_size <= 0) - /* there's no room for data so we stop */ + if(channel->local.window_size <= 0) { + /* there's no room for data so we stop. */ + + /* Waiting on the socket to be writable would be wrong + * because we would be back here immediately, but a readable + * socket might herald an incoming window adjustment. + */ + session->socket_block_directions = LIBSSH2_SESSION_BLOCK_INBOUND; + return (rc==LIBSSH2_ERROR_EAGAIN?rc:0); + } channel->write_bufwrite = buflen; }}} -- Ticket URL: <https://trac.libssh2.org/ticket/258> libssh2 <https://trac.libssh2.org/> C library for writing portable SSH2 clients _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel