summaryrefslogtreecommitdiff
path: root/evutil.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-05-20 12:30:40 -0400
committerNick Mathewson <nickm@torproject.org>2013-05-20 12:30:40 -0400
commit1f29b18f51cb7080c1ffe5f51557979b71451b6a (patch)
tree48f5df2c5a3cfd24a34078fb91305da83f2f6ea9 /evutil.c
parent42c03da9b994e33b7a20ee4d4e70b0a903e230ac (diff)
downloadlibevent-1f29b18f51cb7080c1ffe5f51557979b71451b6a.tar.gz
Avoid redundant syscall if making a socket cloexec twice
I got the idea from Maxime's last patch.
Diffstat (limited to 'evutil.c')
-rw-r--r--evutil.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/evutil.c b/evutil.c
index ce3ef31c..60e6986b 100644
--- a/evutil.c
+++ b/evutil.c
@@ -390,9 +390,11 @@ evutil_make_socket_closeonexec(evutil_socket_t fd)
event_warn("fcntl(%d, F_GETFD)", fd);
return -1;
}
- if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
- event_warn("fcntl(%d, F_SETFD)", fd);
- return -1;
+ if (!(flags & FD_CLOEXEC)) {
+ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
+ event_warn("fcntl(%d, F_SETFD)", fd);
+ return -1;
+ }
}
#endif
return 0;