exit(EXIT_FAILURE); /* do not unlink socket */
}
add_close_on_fork_list(fd);
+ mark_fd_nonblock(fd);
return fd;
}
ret = fd[1];
PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret);
add_close_on_fork_list(ret);
+ mark_fd_nonblock(ret);
} else
clean_exit(EXIT_FAILURE, "failed to open status pipe");
return ret;
#include "para.h"
#include "error.h"
#include "dccp.h"
+#include "fd.h"
/** \cond some magic dccp constants */
#define SOL_DCCP 269
ret = -E_DCCP_CONNECT;
if (connect(pdd->fd, ai->ai_addr, ai->ai_addrlen) < 0)
goto err_out;
+ mark_fd_nonblock(pdd->fd);
return 1;
err_out:
dccp_recv_close(rn);
*/
void para_fd_set(int fd, fd_set *fds, int *max_fileno)
{
+
if (fd < 0 || fd >= FD_SETSIZE) {
PARA_EMERG_LOG("fatal: tried to add invalid fd %d\n", fd);
exit(EXIT_FAILURE);
}
+#if 0
+ {
+ int flags = fcntl(fd, F_GETFL);
+ if (!(flags & O_NONBLOCK)) {
+ PARA_EMERG_LOG("fd %d is a blocking file descriptor\n", fd);
+ exit(EXIT_FAILURE);
+ }
+ }
+#endif
FD_SET(fd, fds);
*max_fileno = PARA_MAX(*max_fileno, fd);
}
if (!ret < 0)
goto err_out;
/* get new socket */
- ret = -E_SOCKET;
- if ((phd->fd = get_socket()) < 0)
+ ret = get_socket();
+ if (ret < 0)
goto err_out;
+ phd->fd = ret;
/* init their_addr */
init_sockaddr(&their_addr, conf->port_arg, he);
/* connect */
ret = para_connect(phd->fd, &their_addr);
if (ret < 0)
goto err_out;
+ mark_fd_nonblock(phd->fd);
phd->status = HTTP_CONNECTED;
return 1;
err_out:
sit->task.post_select = stdin_post_select;
sit->task.event_handler = stdin_default_event_handler;
sit->task.private_data = sit;
+ mark_fd_nonblock(STDIN_FILENO);
sprintf(sit->task.status, "stdin reader");
}
sot->task.post_select = stdout_post_select;
sot->task.event_handler = stdout_default_event_handler;
sot->eof = 0;
+ mark_fd_nonblock(STDOUT_FILENO);
sprintf(sot->task.status, "stdout writer");
}