summaryrefslogtreecommitdiffstats
path: root/src/socket.c
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2011-08-06 10:31:43 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-07 12:46:47 +0200
commita1ef27c0b882d0791ab29584f015d1f8bee44996 (patch)
tree708657551f17d11310909cb8fc06d3724bd8f610 /src/socket.c
parentfb8f2cd11b938f0b1fe660df7630c0eee47b27ff (diff)
downloadlibssh-a1ef27c0b882d0791ab29584f015d1f8bee44996.tar.gz
libssh-a1ef27c0b882d0791ab29584f015d1f8bee44996.tar.xz
libssh-a1ef27c0b882d0791ab29584f015d1f8bee44996.zip
channels: Fix checking for fatal errors.
We need this that we don't end up in and infinite poll loop. (cherry picked from commit 563fbe4de8ee090b40b50415a86f9a3da16f46b0) Conflicts: src/poll.c
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/socket.c b/src/socket.c
index 5d92b6c9..062739ae 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -246,32 +246,34 @@ int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, socket_t fd, int r
s->read_wontblock=1;
r=ssh_socket_unbuffered_read(s,buffer,sizeof(buffer));
if(r<0){
- if(p != NULL) {
- ssh_poll_remove_events(p, POLLIN);
- }
+ if(p != NULL) {
+ ssh_poll_remove_events(p, POLLIN);
+ }
if(s->callbacks && s->callbacks->exception){
s->callbacks->exception(
SSH_SOCKET_EXCEPTION_ERROR,
s->last_errno,s->callbacks->userdata);
- /* p may have been freed, so don't use it
- * anymore in this function */
- p = NULL;
+ /* p may have been freed, so don't use it
+ * anymore in this function */
+ p = NULL;
+ return -2;
}
}
if(r==0){
- if(p != NULL) {
- ssh_poll_remove_events(p, POLLIN);
- }
- if(p != NULL) {
- ssh_poll_remove_events(p, POLLIN);
- }
+ if(p != NULL) {
+ ssh_poll_remove_events(p, POLLIN);
+ }
+ if(p != NULL) {
+ ssh_poll_remove_events(p, POLLIN);
+ }
if(s->callbacks && s->callbacks->exception){
s->callbacks->exception(
SSH_SOCKET_EXCEPTION_EOF,
0,s->callbacks->userdata);
- /* p may have been freed, so don't use it
- * anymore in this function */
- p = NULL;
+ /* p may have been freed, so don't use it
+ * anymore in this function */
+ p = NULL;
+ return -2;
}
}
if(r>0){
@@ -282,9 +284,9 @@ int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, socket_t fd, int r
buffer_get_rest_len(s->in_buffer),
s->callbacks->userdata);
buffer_pass_bytes(s->in_buffer,r);
- /* p may have been freed, so don't use it
- * anymore in this function */
- p = NULL;
+ /* p may have been freed, so don't use it
+ * anymore in this function */
+ p = NULL;
}
}
}