utils: port set_nonblocking() to WIN32
The new WIN32 version of set_nonblocking() can only deal with sockets, i.e. it will fail on main_notify.c. On WIN32, we have to reimplement main_notify.c anyway, so this is not a big deal.
This commit is contained in:
parent
bb55ec6b4e
commit
6890183c50
@ -192,6 +192,11 @@ char *parsePath(char *path)
|
|||||||
|
|
||||||
int set_nonblocking(int fd)
|
int set_nonblocking(int fd)
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
u_long val = 0;
|
||||||
|
|
||||||
|
return ioctlsocket(fd, FIONBIO, &val) == 0 ? 0 : -1;
|
||||||
|
#else
|
||||||
int ret, flags;
|
int ret, flags;
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
@ -203,6 +208,7 @@ int set_nonblocking(int fd)
|
|||||||
flags |= O_NONBLOCK;
|
flags |= O_NONBLOCK;
|
||||||
while ((ret = fcntl(fd, F_SETFL, flags)) < 0 && errno == EINTR) ;
|
while ((ret = fcntl(fd, F_SETFL, flags)) < 0 && errno == EINTR) ;
|
||||||
return ret;
|
return ret;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_async_pipe(int file_des[2])
|
void init_async_pipe(int file_des[2])
|
||||||
|
Loading…
Reference in New Issue
Block a user