From e7f4c5362b313e84bf048b87c35deea21d564a4b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 6 Oct 2010 23:38:17 +0200 Subject: [PATCH] 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. --- udp_send.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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) -- 2.39.2