diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-04-24 22:46:19 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-04-24 22:46:19 +0200 |
commit | 6cdbc01208dad2113effda008be4f529b424a6d7 (patch) | |
tree | c8fec88adf742c1aad7d48ec194755eea403dcd8 /examples | |
parent | 833903e8ec23977ff8dde0be10717ccec0f85202 (diff) | |
download | libssh-6cdbc01208dad2113effda008be4f529b424a6d7.tar.gz libssh-6cdbc01208dad2113effda008be4f529b424a6d7.tar.xz libssh-6cdbc01208dad2113effda008be4f529b424a6d7.zip |
Fixes infinite loops
Thanks to Xi Wang for the patches
Diffstat (limited to 'examples')
-rw-r--r-- | examples/sample.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/sample.c b/examples/sample.c index c8476354..040a2e16 100644 --- a/examples/sample.c +++ b/examples/sample.c @@ -240,7 +240,7 @@ static void select_loop(ssh_session session,ssh_channel channel){ channels[0]=NULL; } if(channels[0]){ - while(channel && channel_is_open(channel) && channel_poll(channel,0)){ + while(channel && channel_is_open(channel) && channel_poll(channel,0)>0){ lus=channel_read_buffer(channel,readbuf,0,0); if(lus==-1){ fprintf(stderr, "Error reading channel: %s\n", @@ -259,7 +259,7 @@ static void select_loop(ssh_session session,ssh_channel channel){ return; } } - while(channel && channel_is_open(channel) && channel_poll(channel,1)){ /* stderr */ + while(channel && channel_is_open(channel) && channel_poll(channel,1)>0){ /* stderr */ lus=channel_read_buffer(channel,readbuf,0,1); if(lus==-1){ fprintf(stderr, "Error reading channel: %s\n", @@ -332,7 +332,7 @@ static void select_loop(ssh_session session,ssh_channel channel){ channels[0]=NULL; } if(outchannels[0]){ - while(channel && channel_is_open(channel) && channel_poll(channel,0)){ + while(channel && channel_is_open(channel) && channel_poll(channel,0)>0){ lus=channel_read(channel,buffer,sizeof(buffer),0); if(lus==-1){ fprintf(stderr, "Error reading channel: %s\n", @@ -351,7 +351,7 @@ static void select_loop(ssh_session session,ssh_channel channel){ return; } } - while(channel && channel_is_open(channel) && channel_poll(channel,1)){ /* stderr */ + while(channel && channel_is_open(channel) && channel_poll(channel,1)>0){ /* stderr */ lus=channel_read(channel,buffer,sizeof(buffer),1); if(lus==-1){ fprintf(stderr, "Error reading channel: %s\n", |