diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-06-17 01:52:11 +0000 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-06-17 01:52:11 +0000 |
commit | 372d1e727b03eadd1f7c707cc08ed5203bac9921 (patch) | |
tree | 2dd2904ecfc38808e60c30b2590bf831807d165d /libssh | |
parent | ff515b55282a62cb7c39d7c72d48fa8e1d2b11e4 (diff) | |
download | libssh-372d1e727b03eadd1f7c707cc08ed5203bac9921.tar.gz libssh-372d1e727b03eadd1f7c707cc08ed5203bac9921.tar.xz libssh-372d1e727b03eadd1f7c707cc08ed5203bac9921.zip |
fixed a bug in the channel windows.
Fixed the window growing on packet receive
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@175 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh')
-rw-r--r-- | libssh/channels.c | 22 | ||||
-rw-r--r-- | libssh/session.c | 2 |
2 files changed, 13 insertions, 11 deletions
diff --git a/libssh/channels.c b/libssh/channels.c index 09ae3982..8b4d40b2 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -26,8 +26,8 @@ MA 02111-1307, USA. */ #include "libssh/priv.h" #include "libssh/ssh2.h" -#define WINDOWLIMIT 1024 -#define WINDOWBASE 32000 +#define WINDOWLIMIT 2048 +#define WINDOWBASE 64000 /** \defgroup ssh_channel SSH Channels * \brief functions that manage a channel @@ -155,7 +155,7 @@ static void grow_window(SSH_SESSION *session, CHANNEL *channel){ buffer_add_u32(session->out_buffer,htonl(channel->remote_channel)); buffer_add_u32(session->out_buffer,htonl(new_window)); packet_send(session); - ssh_say(3,"growing window (channel %d:%d) to %d bytes\n", + ssh_log(session,SSH_LOG_PROTOCOL,"growing window (channel %d:%d) to %d bytes", channel->local_channel,channel->remote_channel, channel->local_window + new_window); channel->local_window+=new_window; @@ -190,7 +190,7 @@ static void channel_rcv_change_window(SSH_SESSION *session){ return; } bytes=ntohl(bytes); - ssh_say(3,"Adding %d bytes to channel (%d:%d) (from %d bytes)\n",bytes, + ssh_log(session,SSH_LOG_PROTOCOL,"Adding %d bytes to channel (%d:%d) (from %d bytes)",bytes, channel->local_channel,channel->remote_channel,channel->remote_window); channel->remote_window+=bytes; leave_function(); @@ -219,17 +219,18 @@ static void channel_rcv_data(SSH_SESSION *session,int is_stderr){ leave_function(); return; } - ssh_say(3,"adding %d bytes data in %d\n",string_len(str),is_stderr); + ssh_log(session,SSH_LOG_PROTOCOL,"Channel receiving %d bytes data in %d (local win=%d remote win=%d)",string_len(str),is_stderr, + channel->local_window,channel->remote_window); /* what shall we do in this case ? let's accept it anyway */ if(string_len(str)>channel->local_window) - ssh_say(0,"Data packet too big for our window(%d vs %d)",string_len(str),channel->local_window); + ssh_log(session,SSH_LOG_RARE,"Data packet too big for our window(%d vs %d)",string_len(str),channel->local_window); channel_default_bufferize(channel,str->string,string_len(str), is_stderr); - if(string_len(str)>=channel->local_window) + if(string_len(str)<=channel->local_window) channel->local_window-=string_len(str); else channel->local_window=0; /* buggy remote */ - if(channel->local_window < WINDOWLIMIT) - grow_window(session,channel); /* i wonder if this is the correct place to do that */ + ssh_log(session,SSH_LOG_PROTOCOL,"Channel windows are now (local win=%d remote win=%d)", + channel->local_window,channel->remote_window); free(str); leave_function(); } @@ -852,7 +853,8 @@ int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr){ } packet_parse(session); } - + if(channel->local_window < WINDOWLIMIT) + grow_window(session,channel); if(bytes==0){ /* write the ful buffer informations */ buffer_add_data(buffer,buffer_get_rest(stdbuf),buffer_get_rest_len(stdbuf)); diff --git a/libssh/session.c b/libssh/session.c index b346ddb4..264855b7 100644 --- a/libssh/session.c +++ b/libssh/session.c @@ -182,7 +182,7 @@ int ssh_handle_packets(SSH_SESSION *session){ } packet_parse(session); ++i; - } while(r>0 && i<5); + } while(r>0); leave_function(); return r; } |