workaround for the bug #14
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@162 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
родитель
c2f151ab56
Коммит
41475a2a1f
@ -766,6 +766,9 @@ int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr){
|
||||
BUFFER *stdbuf=NULL;
|
||||
int len;
|
||||
buffer_reinit(buffer);
|
||||
int maxread=bytes;
|
||||
if(bytes==0)
|
||||
maxread=MAX_PACKET_LEN;
|
||||
/* maybe i should always set a buffer to avoid races between channel_default_bufferize and channel_read */
|
||||
if(is_stderr)
|
||||
stdbuf=channel->stderr_buffer;
|
||||
@ -778,6 +781,8 @@ int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr){
|
||||
return 0;
|
||||
if(channel->remote_eof)
|
||||
break; /* return the resting bytes in buffer */
|
||||
if(buffer_get_rest_len(stdbuf)>=maxread) // stop reading when buffer is full enough
|
||||
break;
|
||||
if(packet_read(channel->session)||packet_translate(channel->session))
|
||||
return -1;
|
||||
packet_parse(channel->session);
|
||||
|
@ -162,7 +162,7 @@ void ssh_set_fd_except(SSH_SESSION *session){
|
||||
*/
|
||||
/* looks if there is data to read on the socket and parse it. */
|
||||
int ssh_handle_packets(SSH_SESSION *session){
|
||||
int w,err,r;
|
||||
int w,err,r,i=0;
|
||||
do {
|
||||
r=ssh_fd_poll(session,&w,&err);
|
||||
if(r<=0)
|
||||
@ -171,7 +171,8 @@ int ssh_handle_packets(SSH_SESSION *session){
|
||||
if(packet_read(session)||packet_translate(session))
|
||||
return -1;
|
||||
packet_parse(session);
|
||||
} while(r>0);
|
||||
++i;
|
||||
} while(r>0 && i<5);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user