X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=udp_send.c;h=04e2982f86bf125c5b4ce8ab2d6daa9280ea0bce;hp=0ea95e41993c0c3442ff0fc219c2111f73e5e0f1;hb=e7f035b3ad7ecc64ec87d9ce890f89365dec1411;hpb=1f12ea375358a0b30689e01efe82796ea4fcb14f diff --git a/udp_send.c b/udp_send.c index 0ea95e41..04e2982f 100644 --- a/udp_send.c +++ b/udp_send.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2005 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2005 Andre Noll , see file COPYING. */ /** \file udp_send.c Para_server's udp sender. */ @@ -22,13 +18,13 @@ #include "error.h" #include "string.h" #include "afh.h" +#include "net.h" #include "server.h" #include "list.h" #include "send.h" #include "sched.h" #include "vss.h" #include "portable_io.h" -#include "net.h" #include "fd.h" #include "close_on_fork.h" @@ -76,8 +72,11 @@ static void udp_delete_target(struct sender_client *sc, const char *msg) PARA_NOTICE_LOG("deleting %s (%s) from list\n", sc->name, msg); udp_close_target(sc); - close(sc->fd); - del_close_on_fork_list(sc->fd); + /* command handlers already called close_listed_fds() */ + if (!process_is_command_handler()) { + close(sc->fd); + del_close_on_fork_list(sc->fd); + } vss_del_fec_client(ut->fc); list_del(&sc->node); free(sc->name); @@ -168,6 +167,13 @@ static void udp_shutdown_targets(void) udp_close_target(sc); } +static void udp_shutdown(void) +{ + struct sender_client *sc, *tmp; + list_for_each_entry_safe(sc, tmp, &targets, node) + udp_delete_target(sc, "shutdown"); +} + static int udp_resolve_target(const char *url, struct sender_command_data *scd) { const char *result; @@ -416,32 +422,38 @@ static char *udp_help(void) ); } -/** - * The init function of para_server's udp sender. - * - * \param s Pointer to the udp sender struct. - * - * It initializes all function pointers of \a s and the list of udp targets. - */ -void udp_send_init(struct sender *s) +/* Initialize the list of udp targets. */ +static void udp_send_init(void) { INIT_LIST_HEAD(&targets); - s->status = udp_status; - s->help = udp_help; - s->send = NULL; - s->pre_select = NULL; - s->post_select = NULL; - s->shutdown_clients = udp_shutdown_targets; - s->resolve_target = udp_resolve_target; - s->client_cmds[SENDER_on] = udp_com_on; - s->client_cmds[SENDER_off] = udp_com_off; - s->client_cmds[SENDER_deny] = NULL; - s->client_cmds[SENDER_allow] = NULL; - s->client_cmds[SENDER_add] = udp_com_add; - s->client_cmds[SENDER_delete] = udp_com_delete; sender_status = SENDER_off; udp_init_target_list(); if (!OPT_GIVEN(UDP_NO_AUTOSTART)) sender_status = SENDER_on; PARA_DEBUG_LOG("udp sender init complete\n"); } + +/** + * The UDP sender. + * + * In contrast to the other senders the UDP sender is active in the sense that + * it initiates the network connection according to its list of targets rather + * than passively waiting for clients to connect. Like DCCP streams, UDP + * streams are always sent FEC-encoded. The UDP sender is the only sender which + * supports IP multicasting. + */ +const struct sender udp_sender = { + .name = "udp", + .init = udp_send_init, + .shutdown = udp_shutdown, + .shutdown_clients = udp_shutdown_targets, + .resolve_target = udp_resolve_target, + .client_cmds = { + [SENDER_on] = udp_com_on, + [SENDER_off] = udp_com_off, + [SENDER_add] = udp_com_add, + [SENDER_delete] = udp_com_delete, + }, + .help = udp_help, + .status = udp_status, +};