Blame SOURCES/0006-_libssh2_channel_write-client-spins-on-write-when-wi.patch

68eb44
From d0a263ef805244245afd9b709bdd3dc733113a6c Mon Sep 17 00:00:00 2001
68eb44
From: Daniel Stenberg <daniel@haxx.se>
68eb44
Date: Sat, 7 Sep 2013 13:41:14 +0200
68eb44
Subject: [PATCH 06/11] _libssh2_channel_write: client spins on write when window full
68eb44
68eb44
When there's no window to "write to", there's no point in waiting for
68eb44
the socket to become writable since it most likely just will continue to
68eb44
be.
68eb44
68eb44
Patch-by: ncm
68eb44
Fixes #258
68eb44
68eb44
[upstream commit e6c46cc249227de7b7cd136d72eded5dcb3f9381]
68eb44
68eb44
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
68eb44
---
68eb44
 src/channel.c |   10 +++++++++-
68eb44
 1 files changed, 9 insertions(+), 1 deletions(-)
68eb44
68eb44
diff --git a/src/channel.c b/src/channel.c
68eb44
index 9f2c241..74262d8 100644
68eb44
--- a/src/channel.c
68eb44
+++ b/src/channel.c
68eb44
@@ -2039,9 +2039,17 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
68eb44
         if((rc < 0) && (rc != LIBSSH2_ERROR_EAGAIN))
68eb44
             return rc;
68eb44
 
68eb44
-        if(channel->local.window_size <= 0)
68eb44
+        if(channel->local.window_size <= 0) {
68eb44
             /* there's no room for data so we stop */
68eb44
+
68eb44
+            /* Waiting on the socket to be writable would be wrong because we
68eb44
+             * would be back here immediately, but a readable socket might
68eb44
+             * herald an incoming window adjustment.
68eb44
+             */
68eb44
+            session->socket_block_directions = LIBSSH2_SESSION_BLOCK_INBOUND;
68eb44
+
68eb44
             return (rc==LIBSSH2_ERROR_EAGAIN?rc:0);
68eb44
+        }
68eb44
 
68eb44
         channel->write_bufwrite = buflen;
68eb44
 
68eb44
-- 
68eb44
1.7.1
68eb44