From: Andre Noll Date: Wed, 6 Oct 2010 21:38:17 +0000 (+0200) Subject: udp: Also send the EOF packet when a target is removed. X-Git-Tag: v0.4.5~2^2~2 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=e7f4c5362b313e84bf048b87c35deea21d564a4b;p=paraslash.git udp: Also send the EOF packet when a target is removed. This notifies the client of the EOF condition and causes it to remove its buffer tree. Without this patch, the client keeps listening which can lead to problems when the target is added later while a different audio file is being streamed. Also there is no point to check twice whether the chunk queue exists. --- diff --git a/udp_send.c b/udp_send.c index 35637f7a..90929857 100644 --- a/udp_send.c +++ b/udp_send.c @@ -54,7 +54,12 @@ static int sender_status; static void udp_close_target(struct sender_client *sc) { + const char *buf; + size_t len = vss_get_fec_eof_packet(&buf); + if (sc->cq != NULL) { + /* ignore return value, closing the target anyway. */ + (void)write(sc->fd, buf, len); cq_destroy(sc->cq); sc->cq = NULL; } @@ -165,15 +170,8 @@ static void udp_init_session(struct sender_client *sc) static void udp_shutdown_targets(void) { struct sender_client *sc, *tmp; - const char *buf; - size_t len = vss_get_fec_eof_packet(&buf); - list_for_each_entry_safe(sc, tmp, &targets, node) - if (sc->cq != NULL) { - /* ignore return value, closing the target anyway. */ - (void)write(sc->fd, buf, len); - udp_close_target(sc); - } + udp_close_target(sc); } static int udp_resolve_target(const char *url, struct sender_command_data *scd)