From 9f7e2c32524052b4b0e234b84195869d950943f9 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Fri, 1 Oct 2010 18:56:57 +0200 Subject: [PATCH] Update the window *after* effective read --- src/channels.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/channels.c b/src/channels.c index cd63d284..1826f5a2 100644 --- a/src/channels.c +++ b/src/channels.c @@ -2142,6 +2142,12 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std ssh_handle_packets(session,-1); } + + len = buffer_get_rest_len(stdbuf); + /* Read count bytes if len is greater, everything otherwise */ + len = (len > count ? count : len); + memcpy(dest, buffer_get_rest(stdbuf), len); + buffer_pass_bytes(stdbuf,len); /* Authorize some buffering while userapp is busy */ if (channel->local_window < WINDOWLIMIT) { if (grow_window(session, channel, 0) < 0) { @@ -2150,12 +2156,6 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std } } - len = buffer_get_rest_len(stdbuf); - /* Read count bytes if len is greater, everything otherwise */ - len = (len > count ? count : len); - memcpy(dest, buffer_get_rest(stdbuf), len); - buffer_pass_bytes(stdbuf,len); - leave_function(); return len; }