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:
27
src/misc.c
27
src/misc.c
@@ -141,19 +141,16 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length,
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
return -wsa2errno();
|
return -wsa2errno();
|
||||||
#elif defined(__VMS)
|
|
||||||
if(rc < 0) {
|
|
||||||
if(errno == EWOULDBLOCK)
|
|
||||||
return -EAGAIN;
|
|
||||||
else
|
|
||||||
return -errno;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if(rc < 0) {
|
if(rc < 0) {
|
||||||
/* Sometimes the first recv() function call sets errno to ENOENT on
|
/* Sometimes the first recv() function call sets errno to ENOENT on
|
||||||
Solaris and HP-UX */
|
Solaris and HP-UX */
|
||||||
if(errno == ENOENT)
|
if(errno == ENOENT)
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
#ifdef EWOULDBLOCK /* For VMS and other special unixes */
|
||||||
|
else if(errno == EWOULDBLOCK)
|
||||||
|
return -EAGAIN;
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
@@ -177,16 +174,14 @@ _libssh2_send(libssh2_socket_t sock, const void *buffer, size_t length,
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
return -wsa2errno();
|
return -wsa2errno();
|
||||||
#elif defined(__VMS)
|
|
||||||
if(rc < 0) {
|
|
||||||
if(errno == EWOULDBLOCK)
|
|
||||||
return -EAGAIN;
|
|
||||||
else
|
|
||||||
return -errno;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if(rc < 0)
|
if(rc < 0) {
|
||||||
return -errno;
|
#ifdef EWOULDBLOCK /* For VMS and other special unixes */
|
||||||
|
if(errno == EWOULDBLOCK)
|
||||||
|
return -EAGAIN;
|
||||||
|
#endif
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user