From 733bf877f8832d3bb73f708e0e9b8f33466ff572 Mon Sep 17 00:00:00 2001 From: Alfred Gebert Date: Tue, 28 Jun 2011 22:43:50 +0200 Subject: [PATCH] _libssh2_recv(): handle ENOENT error as EAGAIN A sftp session failed with error "failure establishing ssh session" on Solaris and HP-UX. Sometimes the first recv() function call sets errno to ENOENT. In the man pages for recv of Solaris and HP-UX the error ENOENT is not documented. I tested Solaris SPARC and x86, HP-UX i64, AIX, Windows and Linux. --- src/misc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/misc.c b/src/misc.c index 592a874..f0bb390 100644 --- a/src/misc.c +++ b/src/misc.c @@ -108,8 +108,14 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags) return -errno; } #else - if (rc < 0 ) - return -errno; + if (rc < 0 ){ + /* Sometimes the first recv() function call sets errno to ENOENT on + Solaris and HP-UX */ + if ( errno == ENOENT ) + return -EAGAIN; + else + return -errno; + } #endif return rc; }