From 29db27970c4be4fc08f31100779758a93ae56f8c Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 29 Jan 2010 09:34:26 +0000 Subject: [PATCH] * src/lib/evil_fcntl.c: * src/lib/evil_fcntl.h: * src/lib/evil_unistd.c: make pipe() blocking by default and allow fcntl() to set a socket to be non-blocking * src/lib/evil_stdlib.c: fix warning SVN revision: 45698 --- legacy/evil/ChangeLog | 11 +++++++++++ legacy/evil/src/lib/evil_fcntl.c | 14 +++++++++++--- legacy/evil/src/lib/evil_fcntl.h | 6 ++++++ legacy/evil/src/lib/evil_stdlib.c | 6 +++--- legacy/evil/src/lib/evil_unistd.c | 4 ++-- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog index a2134fe006..97e9e1b3ec 100644 --- a/legacy/evil/ChangeLog +++ b/legacy/evil/ChangeLog @@ -1,3 +1,14 @@ +2010-01-29 Vincent Torri + + * src/lib/evil_fcntl.c: + * src/lib/evil_fcntl.h: + * src/lib/evil_unistd.c: + make pipe() blocking by default and allow fcntl() + to set a socket to be non-blocking + + * src/lib/evil_stdlib.c: + fix warning + 2010-01-19 Vincent Torri * src/lib/dlfcn/dlfcn.c: diff --git a/legacy/evil/src/lib/evil_fcntl.c b/legacy/evil/src/lib/evil_fcntl.c index 05f920ba56..e713322bbf 100644 --- a/legacy/evil/src/lib/evil_fcntl.c +++ b/legacy/evil/src/lib/evil_fcntl.c @@ -1,4 +1,8 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + #include #ifdef _MSC_VER @@ -9,9 +13,7 @@ # include #endif /* __CEGCC__ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ +#include /* for ioctlsocket */ #include "Evil.h" @@ -64,6 +66,12 @@ int fcntl(int fd, int cmd, ...) res = 0; #endif /* __CEGCC__ || __MINGW32CE__ */ } + if (flag == O_NONBLOCK) + { + u_long arg = 1; + if (ioctlsocket((SOCKET)fd, FIONBIO, &arg) == SOCKET_ERROR) + res = 0; + } } #if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) ) else if ((cmd == F_SETLK) || (cmd == F_SETLKW)) diff --git a/legacy/evil/src/lib/evil_fcntl.h b/legacy/evil/src/lib/evil_fcntl.h index 83cd08d802..e439fd74ec 100644 --- a/legacy/evil/src/lib/evil_fcntl.h +++ b/legacy/evil/src/lib/evil_fcntl.h @@ -13,6 +13,12 @@ */ # define FD_CLOEXEC 1 +/** + * @def O_NONBLOCK + * Specifies that the socket is in non-blocking mode. + */ +# define O_NONBLOCK 04000 + /** * @def F_SETFD * Specifies that fcntl() should set the file descriptor flags diff --git a/legacy/evil/src/lib/evil_stdlib.c b/legacy/evil/src/lib/evil_stdlib.c index 325763bf99..69e1cbdbd2 100644 --- a/legacy/evil/src/lib/evil_stdlib.c +++ b/legacy/evil/src/lib/evil_stdlib.c @@ -322,7 +322,7 @@ mkstemp(char *__template) #if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) ) fd = _open(__template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE); -#else /* __CEGCC__ || __MINGW32CE__ */ +#else /* _WIN32_WCE */ { FILE *f; wchar_t *wtemplate; @@ -339,9 +339,9 @@ mkstemp(char *__template) #endif /* HAVE_ERRNO_H */ return -1; } - fd = _fileno(f); + fd = (int)_fileno(f); } -#endif /* __CEGCC__ || __MINGW32CE__ */ +#endif /* _WIN32_WCE */ if (fd >= 0) return fd; diff --git a/legacy/evil/src/lib/evil_unistd.c b/legacy/evil/src/lib/evil_unistd.c index e22dfabf02..32c233560e 100644 --- a/legacy/evil/src/lib/evil_unistd.c +++ b/legacy/evil/src/lib/evil_unistd.c @@ -382,11 +382,11 @@ evil_pipe(int *fds) if (!FD_ISSET (socket1, &write_set)) goto out2; - arg = 1; + arg = 0; if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR) goto out2; - arg = 1; + arg = 0; if (ioctlsocket (socket2, FIONBIO, &arg) == SOCKET_ERROR) goto out2;