static int dccp_com_on(__a_unused struct sender_command_data *scd)
{
- return generic_com_on(dss, IPPROTO_DCCP);
+ generic_com_on(dss, IPPROTO_DCCP);
+ return 1;
}
static int dccp_com_off(__a_unused struct sender_command_data *scd)
*/
void dccp_send_init(struct sender *s)
{
- int ret;
-
s->status = dccp_status;
s->send = NULL;
s->pre_select = dccp_pre_select;
init_sender_status(dss, OPT_RESULT(DCCP_ACCESS),
OPT_UINT32_VAL(DCCP_PORT), OPT_UINT32_VAL(DCCP_MAX_CLIENTS),
OPT_GIVEN(DCCP_DEFAULT_DENY));
- ret = generic_com_on(dss, IPPROTO_DCCP);
- if (ret < 0)
- PARA_ERROR_LOG("%s\n", para_strerror(-ret));
+ generic_com_on(dss, IPPROTO_DCCP);
}
static int http_com_on(__a_unused struct sender_command_data *scd)
{
- return generic_com_on(hss, IPPROTO_TCP);
+ generic_com_on(hss, IPPROTO_TCP);
+ return 1;
}
static int http_com_off(__a_unused struct sender_command_data *scd)
*/
void http_send_init(struct sender *s)
{
- int ret;
s->status = http_status;
s->send = http_send;
s->pre_select = http_pre_select;
OPT_GIVEN(HTTP_DEFAULT_DENY));
if (OPT_GIVEN(HTTP_NO_AUTOSTART))
return;
- ret = generic_com_on(hss, IPPROTO_TCP);
- if (ret < 0)
- PARA_ERROR_LOG("%s\n", para_strerror(-ret));
+ generic_com_on(hss, IPPROTO_TCP);
}
struct sender_status *ss);
void generic_com_deny(struct sender_command_data *scd,
struct sender_status *ss);
-int generic_com_on(struct sender_status *ss, unsigned protocol);
+void generic_com_on(struct sender_status *ss, unsigned protocol);
void generic_com_off(struct sender_status *ss);
char *generic_sender_help(void);
struct sender_client *accept_sender_client(struct sender_status *ss, fd_set *rfds);
* Activate a paraslash sender.
*
* \param ss The sender to activate.
- * \param protocol The symbolic name of the transport-layer protocol.
+ * \param protocol layer4 type (IPPROTO_TCP or IPPROTO_DCCP).
*
- * \return Standard.
+ * This opens a passive socket of given layer4 type, sets the resulting file
+ * descriptor to nonblocking mode and adds it to the close on fork list.
+ *
+ * Errors are logged but otherwise ignored.
*/
-int generic_com_on(struct sender_status *ss, unsigned protocol)
+void generic_com_on(struct sender_status *ss, unsigned protocol)
{
int fd, ret;
if (ss->listen_fd >= 0)
- return 1;
+ return;
ret = para_listen_simple(protocol, ss->port);
- if (ret < 0)
- return ret;
+ if (ret < 0) {
+ PARA_ERROR_LOG("could not listen on port %d: %s\n", ss->port,
+ para_strerror(-ret));
+ return;
+ }
fd = ret;
ret = mark_fd_nonblocking(fd);
if (ret < 0) {
+ PARA_ERROR_LOG("could not set %s socket fd for port %d to "
+ "nonblocking mode: %s\n",
+ protocol == IPPROTO_TCP? "TCP" : "DCCP", ss->port,
+ para_strerror(-ret));
close(fd);
- return ret;
+ return;
}
add_close_on_fork_list(fd);
ss->listen_fd = ret;
- return 1;
+ return;
}
/**