Peter Stuge wrote:
> > I promised to take a look but I haven't had a chance. I will get
> > to it right now and send an update in a bit.
>
> The most likely way for select() to end up with all empty fd_sets
> is in _libssh2_wait_socket(), if libssh2_session_block_directions()
> returns 0.
While I ponder the explanation and try to get my head around the code
a bit more, here is a patch that will change the hang behavior. I am
not sure this is a fix, but it will make something happen. :)
Those who can reproduce this problem, please test and report back.
Thanks!
//Peter
diff --git a/src/session.c b/src/session.c
index 92109b4..7628f0d 100644
--- a/src/session.c
+++ b/src/session.c
@@ -501,7 +501,7 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session)
fd_set *writefd = NULL;
fd_set *readfd = NULL;
int dir;
- int rc;
+ int rc = 0;
FD_ZERO(&fd);
FD_SET(session->socket_fd, &fd);
@@ -517,7 +517,8 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session)
/* Note that this COULD be made to use a timeout that perhaps could be
customizable by the app or something... */
- rc = select(session->socket_fd + 1, readfd, writefd, NULL, NULL);
+ if(readfd || writefd)
+ rc = select(session->socket_fd + 1, readfd, writefd, NULL, NULL);
if(rc <= 0) {
/* timeout (or error), bail out with a timeout error */
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel