struct dccp_client *dc;
int ret;
- if (!FD_ISSET(listen_fd, rfds))
+ if (listen_fd < 0 || !FD_ISSET(listen_fd, rfds))
return;
ret = para_accept(listen_fd, NULL, 0);
if (ret < 0) {
s->client_cmds[SENDER_DELETE] = NULL;
self = s;
ret = dccp_open();
- if (ret < 0) {
+ if (ret < 0)
PARA_ERROR_LOG("%s\n", para_strerror(-ret));
- s->status = SENDER_OFF;
- } else
- s->status = SENDER_ON;
}
struct http_client *hc, *tmp;
const char *err_msg;
+ if (server_fd < 0)
+ return;
list_for_each_entry_safe(hc, tmp, &clients, node) {
i++;
// PARA_DEBUG_LOG("handling client %d: %s\n", i, remote_name(hc->fd));
server_fd = para_listen(AF_UNSPEC, IPPROTO_TCP, port);
if (server_fd < 0) {
http_shutdown_clients();
- self->status = SENDER_OFF;
return server_fd;
}
ret = mark_fd_nonblocking(server_fd);
PARA_EMERG_LOG("%s\n", para_strerror(-ret));
exit(EXIT_FAILURE);
}
- self->status = SENDER_ON;
add_close_on_fork_list(server_fd);
return 1;
}
static int http_com_on(__a_unused struct sender_command_data *scd)
{
- if (self->status == SENDER_ON)
+ if (server_fd >= 0)
return 1;
return http_open(conf.http_port_arg);
}
static int http_com_off(__a_unused struct sender_command_data *scd)
{
- self->status = SENDER_OFF;
- if (server_fd > 0) {
- close(server_fd);
- del_close_on_fork_list(server_fd);
- server_fd = -1;
- }
+ if (server_fd < 0)
+ return 1;
+ PARA_NOTICE_LOG("closing http port %d\n", conf.http_port_arg);
+ close(server_fd);
+ del_close_on_fork_list(server_fd);
http_shutdown_clients();
+ server_fd = -1;
return 1;
}
"http maximal number of clients: %d%s\n"
"http connected clients: %s\n"
"http access %s list: %s\n",
- (self->status == SENDER_ON)? "on" : "off",
+ (server_fd >= 0)? "on" : "off",
conf.http_port_arg,
numclients,
conf.http_max_clients_arg,
static struct list_head targets;
static struct sender *self;
+static int sender_status;
static void ortp_delete_target(struct ortp_target *ot, const char *msg)
{
char *sendbuf, *header_buf = NULL;
struct timeval *chunk_tv;
- if (self->status != SENDER_ON)
+ if (sender_status != SENDER_ON)
return;
// PARA_NOTICE_LOG("sending %lu\n", current_chunk);
static int ortp_com_on(__a_unused struct sender_command_data *scd)
{
- self->status = SENDER_ON;
+ sender_status = SENDER_ON;
return 1;
}
static int ortp_com_off(__a_unused struct sender_command_data *scd)
{
ortp_shutdown_targets();
- self->status = SENDER_OFF;
+ sender_status = SENDER_OFF;
return 1;
}
"ortp status: %s\n"
"ortp default port: udp %d\n"
"ortp targets: %s\n",
- (self->status == SENDER_ON)? "on" : "off",
+ (sender_status == SENDER_ON)? "on" : "off",
conf.ortp_default_port_arg,
tgts? tgts : "(none)"
);
s->client_cmds[SENDER_ADD] = ortp_com_add;
s->client_cmds[SENDER_DELETE] = ortp_com_delete;
self = s;
- s->status = SENDER_OFF;
+ sender_status = SENDER_OFF;
ortp_init_target_list();
if (!conf.ortp_no_autostart_given)
- s->status = SENDER_ON;
+ sender_status = SENDER_ON;
PARA_DEBUG_LOG("%s", "ortp sender init complete\n");
}
* this sending facility, for example it could open a tcp port.
*/
void (*init)(struct sender *s);
-/** \p SENDER_ON or \p SENDER_OFF */
- int status;
/**
* return the help text of this sender
*
timeout = vss_preselect(&rfds, &wfds, &max_fileno);
status_refresh();
for (i = 0; senders[i].name; i++) {
- if (senders[i].status != SENDER_ON)
- continue;
if (!senders[i].pre_select)
continue;
senders[i].pre_select(&max_fileno, &rfds, &wfds);
if (ret < 0)
goto repeat;
for (i = 0; senders[i].name; i++) {
- if (senders[i].status != SENDER_ON)
- continue;
if (!senders[i].post_select)
continue;
senders[i].post_select(&rfds, &wfds);