mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-14 23:05:03 -04:00
Avoid redundant syscall if making a socket cloexec twice
I got the idea from Maxime's last patch.
This commit is contained in:
parent
42c03da9b9
commit
1f29b18f51
8
evutil.c
8
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user