]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
upd_send: Add socket fd to close_on_fork list.
authorAndre Noll <maan@systemlinux.org>
Sat, 10 Jan 2009 16:56:30 +0000 (17:56 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 10 Jan 2009 16:56:30 +0000 (17:56 +0100)
udp_send.c

index 8bbcbae7fa611473d1abd67a65d70506380aa8a5..9e8bc0482cdf79153ded26ad08777bff044f938b 100644 (file)
@@ -25,6 +25,7 @@
 #include "net.h"
 #include "fd.h"
 #include "sched.h"
 #include "net.h"
 #include "fd.h"
 #include "sched.h"
+#include "close_on_fork.h"
 
 
 /** Convert in_addr to ascii. */
 
 
 /** Convert in_addr to ascii. */
@@ -49,8 +50,10 @@ static void udp_delete_target(struct udp_target *ut, const char *msg)
 {
        PARA_NOTICE_LOG("deleting %s:%d (%s) from list\n", TARGET_ADDR(ut),
                ut->port, msg);
 {
        PARA_NOTICE_LOG("deleting %s:%d (%s) from list\n", TARGET_ADDR(ut),
                ut->port, msg);
-       if (ut->fd >= 0)
+       if (ut->fd >= 0) {
                close(ut->fd);
                close(ut->fd);
+               del_close_on_fork_list(ut->fd);
+       }
        list_del(&ut->node);
        free(ut);
 }
        list_del(&ut->node);
        free(ut);
 }
@@ -84,9 +87,12 @@ static int udp_init_session(struct udp_target *ut)
                return ret;
        ut->fd = ret;
        ret = mark_fd_nonblocking(ut->fd);
                return ret;
        ut->fd = ret;
        ret = mark_fd_nonblocking(ut->fd);
-       if (ret < 0)
+       if (ret < 0) {
                close(ut->fd);
                close(ut->fd);
-       return ret;
+               return ret;
+       }
+       add_close_on_fork_list(ut->fd);
+       return 1;
 }
 
 static void udp_shutdown_targets(void)
 }
 
 static void udp_shutdown_targets(void)
@@ -101,6 +107,7 @@ static void udp_shutdown_targets(void)
                        continue;
                write(ut->fd, buf, UDP_AUDIO_HEADER_LEN);
                close(ut->fd);
                        continue;
                write(ut->fd, buf, UDP_AUDIO_HEADER_LEN);
                close(ut->fd);
+               del_close_on_fork_list(ut->fd);
                ut->fd = -1;
        }
 }
                ut->fd = -1;
        }
 }