From b74c8941e36860a34483782cf91e449212401664 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 10 Jan 2009 17:56:30 +0100 Subject: [PATCH] upd_send: Add socket fd to close_on_fork list. --- udp_send.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/udp_send.c b/udp_send.c index 8bbcbae7..9e8bc048 100644 --- a/udp_send.c +++ b/udp_send.c @@ -25,6 +25,7 @@ #include "net.h" #include "fd.h" #include "sched.h" +#include "close_on_fork.h" /** 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); - if (ut->fd >= 0) + if (ut->fd >= 0) { close(ut->fd); + del_close_on_fork_list(ut->fd); + } 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); - if (ret < 0) + if (ret < 0) { close(ut->fd); - return ret; + return ret; + } + add_close_on_fork_list(ut->fd); + return 1; } 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); + del_close_on_fork_list(ut->fd); ut->fd = -1; } } -- 2.39.5