summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
639a900)
This shouldn't matter much, but there _are_ (rare) situations where
an fd is marked ready for reading, but a subsequent read will block
nevertheless. It's never wrong to use non-blocking fds, so just do it.
This patch also includes a check in para_fd_set() which spots blocking
fds as they are added to the fd sets. This check is commented out
for performance reasons but can easily be activated.
exit(EXIT_FAILURE); /* do not unlink socket */
}
add_close_on_fork_list(fd);
exit(EXIT_FAILURE); /* do not unlink socket */
}
add_close_on_fork_list(fd);
ret = fd[1];
PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret);
add_close_on_fork_list(ret);
ret = fd[1];
PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret);
add_close_on_fork_list(ret);
} else
clean_exit(EXIT_FAILURE, "failed to open status pipe");
return ret;
} else
clean_exit(EXIT_FAILURE, "failed to open status pipe");
return ret;
#include "para.h"
#include "error.h"
#include "dccp.h"
#include "para.h"
#include "error.h"
#include "dccp.h"
/** \cond some magic dccp constants */
#define SOL_DCCP 269
/** \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;
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);
return 1;
err_out:
dccp_recv_close(rn);
*/
void para_fd_set(int fd, fd_set *fds, int *max_fileno)
{
*/
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 (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);
}
FD_SET(fd, fds);
*max_fileno = PARA_MAX(*max_fileno, fd);
}
if (!ret < 0)
goto err_out;
/* get new socket */
if (!ret < 0)
goto err_out;
/* get new socket */
- ret = -E_SOCKET;
- if ((phd->fd = get_socket()) < 0)
+ ret = get_socket();
+ if (ret < 0)
/* init their_addr */
init_sockaddr(&their_addr, conf->port_arg, he);
/* connect */
/* 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;
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:
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;
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");
}
sprintf(sit->task.status, "stdin reader");
}
sot->task.post_select = stdout_post_select;
sot->task.event_handler = stdout_default_event_handler;
sot->eof = 0;
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");
}
sprintf(sot->task.status, "stdout writer");
}