manu-S783fYmB3Ccdnm+yROfE0A@... writes:
>> +#ifdef USE_CLOEXEC
>
> Is there a reason why you don't you just include <fcntl.h> and test
> #ifdef FD_CLOEXEC ?
The wrapped
socket(_domain, (_type) | SOCK_CLOEXEC, _protocol)
~~~~~~~~~~~~~~~
call is very runtime specific (requires Linux 2.6.27+) and there are
major Linux distributions which ship older kernels. Doing a buildtime
check seems too risky for me.
>> - if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
>> + if ((sock = socket_cloexec(AF_UNIX, SOCK_STREAM, 0)) == -1) {
>> mg_log(LOG_ERR, "spamd socket failed: %s", strerror(errno));
>> return -1;
>
> I think I would rather do something like this:
>
> if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
> mg_log(LOG_ERR, "spamd socket failed: %s", strerror(errno));
> return -1;
> }
> SET_CLOEXEC(sock);
your decision... I used the socket_cloexec() to generate more efficient
code (especially when SOCK_CLOEXEC works).
EnricoMessage
Re: [PATCH] Set CLOEXEC flags for sockets
2010-06-10 by Enrico Scholz
Attachments
- No local attachments were found for this message.