misc.c : Add an EWOULDBLOCK check for better portability
File: misc.c
Notes: Added support for all OS' that implement EWOULDBLOCK, not only VMS
Credit: hlefebvre
@@ -141,19 +141,16 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length,
#ifdef WIN32
if(rc < 0)
return -wsa2errno();
-#elif defined(__VMS)
- if(rc < 0) {
- if(errno == EWOULDBLOCK)
- return -EAGAIN;
- else
- return -errno;
- }
#else
if(rc < 0) {
/* Sometimes the first recv() function call sets errno to ENOENT on
Solaris and HP-UX */
if(errno == ENOENT)
return -EAGAIN;
+#ifdef EWOULDBLOCK /* For VMS and other special unixes */
+ else if(errno == EWOULDBLOCK)
+ return -EAGAIN;
+#endif
else
return -errno;
}
@@ -177,16 +174,14 @@ _libssh2_send(libssh2_socket_t sock, const void *buffer, size_t length,
#ifdef WIN32
if(rc < 0)
return -wsa2errno();
-#elif defined(__VMS)
+#else
if(rc < 0) {
+#ifdef EWOULDBLOCK /* For VMS and other special unixes */
if(errno == EWOULDBLOCK)
return -EAGAIN;
- else
+#endif
return -errno;
}
-#else
- if(rc < 0)
- return -errno;
#endif
return rc;
}
