]> git.tue.mpg.de Git - paraslash.git/commitdiff
udp: Also send the EOF packet when a target is removed.
authorAndre Noll <maan@systemlinux.org>
Wed, 6 Oct 2010 21:38:17 +0000 (23:38 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 31 Oct 2010 11:18:24 +0000 (12:18 +0100)
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

index 35637f7ada278e9dcfbe06d8447c0ec58aadc457..9092985725b5289ee7391eba3df2c12ae4e62844 100644 (file)
@@ -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)