mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
misc.c : Add an EWOULDBLOCK check for better portability (#172)
File: misc.c Notes: Added support for all OS' that implement EWOULDBLOCK, not only VMS Credit: hlefebvre
This commit is contained in:
19
src/misc.c
19
src/misc.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user