aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-07-07 10:00:09 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-07-07 10:00:09 +0200
commitaf8315b9ce287874e1b374743d6fbaa5fc5c2cfd (patch)
treeea64d36239c6b8c13be86bd4797c54b3a8fc10be
parent94fdcf7a2a5d41220e667cb85d1f485254020d61 (diff)
downloadlibssh-af8315b9ce287874e1b374743d6fbaa5fc5c2cfd.tar.gz
libssh-af8315b9ce287874e1b374743d6fbaa5fc5c2cfd.tar.xz
libssh-af8315b9ce287874e1b374743d6fbaa5fc5c2cfd.zip
Fixed ssh_socket_poll behaviour
-rw-r--r--libssh/socket.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/libssh/socket.c b/libssh/socket.c
index b722462d..402a5b78 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -484,22 +484,19 @@ int ssh_socket_poll(struct socket *s, int *writeable, int *except) {
if (!s->data_to_read) {
fd->events |= POLLIN;
- } else if (!s->data_to_write) {
+ }
+ if (!s->data_to_write) {
fd->events |= POLLOUT;
- } else {
- *except = 1;
- *writeable = 0;
-
- leave_function();
- return 1;
}
-
- /* Make the call, and listen for errors */
- rc = ssh_poll(fd, 1, 0);
- if (rc < 0) {
- ssh_set_error(session, SSH_FATAL, "poll(): %s", strerror(errno));
- leave_function();
- return -1;
+ /* do not do poll if fd->events is empty, we already know the response */
+ if(fd->events != 0){
+ /* Make the call, and listen for errors */
+ rc = ssh_poll(fd, 1, 0);
+ if (rc < 0) {
+ ssh_set_error(session, SSH_FATAL, "poll(): %s", strerror(errno));
+ leave_function();
+ return -1;
+ }
}
if (!s->data_to_read) {