diff options
author | Maxime Henrion <mhenrion@gmail.com> | 2013-05-20 12:23:53 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-05-20 12:23:53 -0400 |
commit | 42c03da9b994e33b7a20ee4d4e70b0a903e230ac (patch) | |
tree | 7ba412992bcc3c15bfafb06430f47c1b08f361dd | |
parent | 9b5a527f5bf898250a797dde59cadb4f64e8967a (diff) | |
download | libevent-42c03da9b994e33b7a20ee4d4e70b0a903e230ac.tar.gz |
Avoid redundant syscall to make a nonblocking socket nonblocking
-rw-r--r-- | evutil.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 |