Subject: [PATCH] _libssh2_recv(): handle ENOENT error as EAGAIN

[PATCH] _libssh2_recv(): handle ENOENT error as EAGAIN

From: Alfred Gebert <alfred.gebert_at_gmail.com>
Date: Tue, 28 Jun 2011 09:35:00 +0200

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 |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/misc.c b/src/misc.c
index 489605c..fefb497 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -108,8 +108,12 @@ _libssh2_recv(libssh2_socket_t sock, void
*buffer, size_t length, int flags)
             return -errno;
     }
 #else
-    if (rc < 0 )
-        return -errno;
+    if (rc < 0 ){
+        if ( errno == ENOENT )
+            return -EAGAIN;
+        else
+            return -errno;
+    }
 #endif
     return rc;
 }
-- 
1.7.3.4
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-06-28