From 25adcc150e542b5c72acba081cb6399a3180b56c Mon Sep 17 00:00:00 2001 From: James Housley Date: Fri, 22 Jun 2007 16:46:36 +0000 Subject: [PATCH] Guenter Knauf submitted code to detect on windows if the socket is blocking or not --- ChangeLog | 8 ++++++-- src/session.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e61191..fe9db7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,14 @@ -2007-07-15 James Housley +2007-06-22 James Housley + * Guenter Knauf submitted code for windows to detect + if the socket is blocking or not. + +2007-06-15 James Housley * Add libssh2_sftp_readdir_ex(), this function if passed the extra parameters will be used to store the full directory entry as provided by the server. Updated LIBSSH2_APINO to 200706151200 for this change. -2007-07-12 James Housley +2007-06-12 James Housley * libssh2_publickey_shutdown(), libssh2_session_free() changed to return an "int" to allow signaling of LIBSSH2_ERROR_EAGAIN. diff --git a/src/session.c b/src/session.c index 3d8369d..b809b75 100644 --- a/src/session.c +++ b/src/session.c @@ -318,6 +318,20 @@ static int _libssh2_get_socket_nonblocking(int sockfd) /* operate on this */ #define GETBLOCK 1 #endif +#if defined(WSAEWOULDBLOCK) && (GETBLOCK == 0) + /* Windows? */ + unsigned int option_value; + socklen_t option_len = sizeof(option_value); + + if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)&option_value, &option_len)) { + /* Assume blocking on error */ + return 1; + } + return (int)option_value; +#undef GETBLOCK +#define GETBLOCK 2 +#endif + #if defined(HAVE_SO_NONBLOCK) && (GETBLOCK == 0) /* BeOS */ long b;