WIN32: Make dup2 a NO-OP under win32.
There is something wrong with dup2 under win32 and I do not know win32 well enough to fix it, thus this workaround. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -208,4 +208,20 @@ ssize_t win32_writev(int fd, const struct iovec *iov, int iovcnt)
|
|||||||
return send(fd, iov[0].iov_base, iov[0].iov_len, 0);
|
return send(fd, iov[0].iov_base, iov[0].iov_len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Something is broken with how I use dup2 for windows and I do not know
|
||||||
|
* win32 API well enought to figure out why, thus our dup2 for win32 will be
|
||||||
|
* a NO-OP.
|
||||||
|
* The only consequence of this is that the filedescriptor for libiscsi may
|
||||||
|
* now suddenly change under win32. As long as the application just calls
|
||||||
|
* iscsi_get_fd() before poll or its equivalent every time ot goes through
|
||||||
|
* its event loop, everything should work.
|
||||||
|
* IF the app tries to be clever/optimized and only calls iscsi_get_fd()
|
||||||
|
* one single time and re-uses that file descriptor number throughout
|
||||||
|
* any future iterations in the event loop, then things will break :-(
|
||||||
|
*/
|
||||||
|
int win32_dup2(int oldfd, int newfd)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ typedef int socklen_t;
|
|||||||
#define writev win32_writev
|
#define writev win32_writev
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strdup _strdup
|
#define strdup _strdup
|
||||||
|
#define dup2(x, y, z) win32_dup2(x, y)
|
||||||
#define poll(x, y, z) win32_poll(x, y, z)
|
#define poll(x, y, z) win32_poll(x, y, z)
|
||||||
#define inet_pton(x,y,z) win32_inet_pton(x,y,z)
|
#define inet_pton(x,y,z) win32_inet_pton(x,y,z)
|
||||||
#define sleep(x) Sleep(x * 1000)
|
#define sleep(x) Sleep(x * 1000)
|
||||||
|
|||||||
Reference in New Issue
Block a user