summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Henrion <mhenrion@gmail.com>2013-05-20 12:23:53 -0400
committerNick Mathewson <nickm@torproject.org>2013-05-20 12:23:53 -0400
commit42c03da9b994e33b7a20ee4d4e70b0a903e230ac (patch)
tree7ba412992bcc3c15bfafb06430f47c1b08f361dd
parent9b5a527f5bf898250a797dde59cadb4f64e8967a (diff)
downloadlibevent-42c03da9b994e33b7a20ee4d4e70b0a903e230ac.tar.gz
Avoid redundant syscall to make a nonblocking socket nonblocking
-rw-r--r--evutil.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/evutil.c b/evutil.c
index e8f5b96d..ce3ef31c 100644
--- a/evutil.c
+++ b/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