CLEANUP: tree-wide: use fd_set_nonblock() and fd_set_cloexec()
This gets rid of most open-coded fcntl() calls, some of which were passed
through DISGUISE() to avoid a useless test. The FD_CLOEXEC was most often
set without preserving previous flags, which could become a problem once
new flags are created. Now this will not happen anymore.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 738d2d1..a160b1b 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -12,7 +12,6 @@
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -341,7 +340,7 @@
return SF_ERR_PRXCOND; /* it is a configuration limit */
}
- if ((fcntl(fd, F_SETFL, O_NONBLOCK)==-1) ||
+ if (fd_set_nonblock(fd) == -1 ||
(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) == -1)) {
qfprintf(stderr,"Cannot set client socket to non blocking mode.\n");
close(fd);
@@ -350,7 +349,7 @@
return SF_ERR_INTERNAL;
}
- if (master == 1 && (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)) {
+ if (master == 1 && fd_set_cloexec(fd) == -1) {
ha_alert("Cannot set CLOEXEC on client socket.\n");
close(fd);
conn->err_code = CO_ER_SOCK_ERR;