Avoid redundant syscall to make a nonblocking socket nonblocking

This commit is contained in:
Maxime Henrion 2013-05-20 12:23:53 -04:00 committed by Nick Mathewson
parent 9b5a527f5b
commit 42c03da9b9

View File

@ -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