socket: Call data handler as long as handler takes data.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Johannes Krude
2013-01-22 13:06:28 +01:00
committed by Aris Adamantiadis
parent f17788adc2
commit d7ab3d7b3d

View File

@@ -280,10 +280,12 @@ int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, socket_t fd, int r
/* Bufferize the data and then call the callback */
buffer_add_data(s->in_buffer,buffer,r);
if(s->callbacks && s->callbacks->data){
r= s->callbacks->data(buffer_get_rest(s->in_buffer),
buffer_get_rest_len(s->in_buffer),
s->callbacks->userdata);
buffer_pass_bytes(s->in_buffer,r);
do {
r= s->callbacks->data(buffer_get_rest(s->in_buffer),
buffer_get_rest_len(s->in_buffer),
s->callbacks->userdata);
buffer_pass_bytes(s->in_buffer,r);
} while (r > 0);
/* p may have been freed, so don't use it
* anymore in this function */
p = NULL;