if (pipe(pipefd) < 0)
goto fail_pipe;
- if (fcntl(pipefd[0], F_SETFD, fcntl(pipefd[0], F_GETFD, FD_CLOEXEC) | FD_CLOEXEC) == -1)
+ if (fd_set_cloexec(pipefd[0]) == -1)
goto fail_fcntl;
- if (fcntl(pipefd[1], F_SETFD, fcntl(pipefd[1], F_GETFD, FD_CLOEXEC) | FD_CLOEXEC) == -1)
+ if (fd_set_cloexec(pipefd[1]) == -1)
goto fail_fcntl;
pid = fork();
*/
#include <errno.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
}
/* Make the socket non blocking */
- fcntl(fd, F_SETFL, O_NONBLOCK);
+ fd_set_nonblock(fd);
/* Add the fd in the fd list and update its parameters */
dgram->t.sock.fd = fd;
if (unlikely(!(fdtab[fd].state & FD_INITIALIZED))) {
HA_ATOMIC_OR(&fdtab[fd].state, FD_INITIALIZED);
if (!isatty(fd))
- fcntl(fd, F_SETFL, O_NONBLOCK);
+ fd_set_nonblock(fd);
}
sent = writev(fd, iovec, vec);
HA_ATOMIC_BTR(&fdtab[fd].state, FD_EXCL_SYSCALL_BIT);
poller_rd_pipe = mypipe[0];
poller_wr_pipe[tid] = mypipe[1];
- fcntl(poller_rd_pipe, F_SETFL, O_NONBLOCK);
+ fd_set_nonblock(poller_rd_pipe);
fd_insert(poller_rd_pipe, poller_pipe_io_handler, poller_pipe_io_handler, tid_bit);
fd_insert(poller_wr_pipe[tid], poller_pipe_io_handler, poller_pipe_io_handler, tid_bit);
fd_want_recv(poller_rd_pipe);
*/
#include <ctype.h>
-#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
setsockopt(*plogfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero));
/* does nothing under Linux, maybe needed for others */
shutdown(*plogfd, SHUT_RD);
- fcntl(*plogfd, F_SETFD, fcntl(*plogfd, F_GETFD, FD_CLOEXEC) | FD_CLOEXEC);
+ fd_set_cloexec(*plogfd);
}
}
#define _GNU_SOURCE
#include <errno.h>
-#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
if (tid != 0)
return 1;
- fcntl(proc_self->ipc_fd[1], F_SETFL, O_NONBLOCK);
+ fd_set_nonblock(proc_self->ipc_fd[1]);
/* In multi-tread, we need only one thread to process
* events on the pipe with master
*/
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
return SF_ERR_PRXCOND; /* it is a configuration limit */
}
- if ((fcntl(fd, F_SETFL, O_NONBLOCK)==-1)) {
+ if (fd_set_nonblock(fd) == -1) {
qfprintf(stderr,"Cannot set client socket to non blocking mode.\n");
close(fd);
conn->err_code = CO_ER_SOCK_ERR;
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;
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
#include <stdio.h>
goto bind_close_return;
}
- if (fcntl(rx->fd, F_SETFL, O_NONBLOCK) == -1) {
+ if (fd_set_nonblock(rx->fd) == -1) {
err |= ERR_FATAL | ERR_ALERT;
memprintf(errmsg, "cannot make socket non-blocking");
goto bind_close_return;
return SF_ERR_PRXCOND; /* it is a configuration limit */
}
- if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
+ if (fd_set_nonblock(fd) == -1) {
qfprintf(stderr,"Cannot set client socket to non blocking mode.\n");
close(sv[0]);
close(sv[1]);
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(sv[0]);
close(sv[1]);
int cfd;
if ((cfd = recv_fd_uxst(l->rx.fd)) != -1)
- DISGUISE(fcntl(cfd, F_SETFL, O_NONBLOCK));
+ fd_set_nonblock(cfd);
if (likely(cfd != -1)) {
/* Perfect, the connection was accepted */
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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);
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;
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
return SF_ERR_PRXCOND; /* it is a configuration limit */
}
- if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
+ if (fd_set_nonblock(fd) == -1) {
qfprintf(stderr,"Cannot set client socket to non blocking mode.\n");
close(fd);
conn->err_code = CO_ER_SOCK_ERR;
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;
#define _GNU_SOURCE
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
{
laddr = sizeof(*conn->src);
if ((cfd = accept(l->rx.fd, (struct sockaddr*)addr, &laddr)) != -1) {
- fcntl(cfd, F_SETFL, O_NONBLOCK);
+ fd_set_nonblock(cfd);
if (master)
- fcntl(cfd, F_SETFD, FD_CLOEXEC);
+ fd_set_cloexec(cfd);
}
}
*/
#include <errno.h>
-#include <fcntl.h>
#include <string.h>
#include <unistd.h>
goto bind_close_return;
}
- if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
+ if (fd_set_nonblock(fd) == -1) {
err |= ERR_FATAL | ERR_ALERT;
memprintf(errmsg, "cannot make socket non-blocking");
goto bind_close_return;
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
#include <string.h>
#include <unistd.h>
goto bind_close_return;
}
- if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
+ if (fd_set_nonblock(fd) == -1) {
err |= ERR_FATAL | ERR_ALERT;
memprintf(errmsg, "cannot make socket non-blocking");
goto bind_close_return;