mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-13 06:16:10 -04:00
Avoid redundant syscall to make a nonblocking socket nonblocking
This commit is contained in:
parent
9b5a527f5b
commit
42c03da9b9
8
evutil.c
8
evutil.c
@ -323,9 +323,11 @@ evutil_make_socket_nonblocking(evutil_socket_t fd)
|
||||
event_warn("fcntl(%d, F_GETFL)", fd);
|
||||
return -1;
|
||||
}
|
||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
|
||||
event_warn("fcntl(%d, F_SETFL)", fd);
|
||||
return -1;
|
||||
if (!(flags & O_NONBLOCK)) {
|
||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
|
||||
event_warn("fcntl(%d, F_SETFL)", fd);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user