From 697b4e8ed7268e635ae7eaaf6b77b522e068467f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 18 Jul 2010 19:47:21 +0200 Subject: [PATCH] libssh2_wait_socket: reset error code to "leak" EAGAIN less Since libssh2 often sets LIBSSH2_ERROR_EAGAIN internally before _libssh2_wait_socket is called, we can decrease some amount of confusion in user programs by resetting the error code in this function to reduce the risk of EAGAIN being stored as error when a blocking function returns. --- src/session.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/session.c b/src/session.c index 6234ee1..6371941 100644 --- a/src/session.c +++ b/src/session.c @@ -543,6 +543,12 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session) int seconds_to_next; int dir; + /* since libssh2 often sets EAGAIN internally before this function is + called, we can decrease some amount of confusion in user programs by + resetting the error code in this function to reduce the risk of EAGAIN + being stored as error when a blocking function has returned */ + session->err_code = LIBSSH2_ERROR_NONE; + rc = libssh2_keepalive_send (session, &seconds_to_next); if (rc < 0) return rc;