mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-15 15:25:09 -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
2
evutil.c
2
evutil.c
@ -390,10 +390,12 @@ evutil_make_socket_closeonexec(evutil_socket_t fd)
|
|||||||
event_warn("fcntl(%d, F_GETFD)", fd);
|
event_warn("fcntl(%d, F_GETFD)", fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (!(flags & FD_CLOEXEC)) {
|
||||||
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
|
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
|
||||||
event_warn("fcntl(%d, F_SETFD)", fd);
|
event_warn("fcntl(%d, F_SETFD)", fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user