Here is a little patch, I am not sure it's 100% ok, it does not resolve the problem entirely, it only handles LIBSSH2_ERROR_SOCKET_DISCONNECT. Maybe just returning "rc" would be better.
--------- Original Message ---------Subject: Re: libssh2_userauth_password return value From: Peter Stuge <pe...@stuge.se> Date: 4/17/13 3:07 pm To: libssh2-devel@cool.haxx.se cos...@5ivestars.net wrote: > } else if (rc) { > session->userauth_pswd_state = libssh2_NB_state_idle; > return _libssh2_error(session, LIBSSH2_ERROR_TIMEOUT, > "Would block waiting"); > } > > I think it should return the actual error from the transport layer > and not a "general" LIBSSH2_ERROR_TIMEOUT error. Could you send a patch to fix that? Thanks. //Peter _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
--- src/userauth.c 2012-04-18 23:24:04.000000000 +0300 +++ src/userauth.new.c 2013-04-17 15:51:03.275687538 +0300 @@ -280,9 +280,15 @@ return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block waiting"); } else if (rc) { - session->userauth_pswd_state = libssh2_NB_state_idle; - return _libssh2_error(session, LIBSSH2_ERROR_TIMEOUT, - "Would block waiting"); + if (rc == LIBSSH2_ERROR_SOCKET_DISCONNECT ) { + session->userauth_pswd_state = libssh2_NB_state_idle; + return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_DISCONNECT, + "Connection closed by server"); + } else { + session->userauth_pswd_state = libssh2_NB_state_idle; + return _libssh2_error(session, LIBSSH2_ERROR_TIMEOUT, + "Would block waiting"); + } } if (session->userauth_pswd_data[0] == SSH_MSG_USERAUTH_SUCCESS) {
_______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel