]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - udp_send.c
Fix an fd leak in udp_send.c.
[paraslash.git] / udp_send.c
index 61cab430c04dca75f1e89c5e4821be3b24328dfe..50161c1333642d2021b47c3b0a05ff4bd43f10f6 100644 (file)
@@ -79,12 +79,15 @@ static int udp_init_session(struct udp_target *ut)
        if (ut->fd >= 0) /* nothing to do */
                return 0;
        PARA_NOTICE_LOG("sending to udp %s:%d\n", TARGET_ADDR(ut), ut->port);
-       /* TODO: Make ttl configurable. */
-       ret = create_udp_send_socket(TARGET_ADDR(ut), ut->port, 10);
+       ret = create_udp_send_socket(TARGET_ADDR(ut), ut->port,
+               conf.udp_ttl_arg);
        if (ret < 0)
                return ret;
        ut->fd = ret;
-       return mark_fd_nonblocking(ut->fd);
+       ret = mark_fd_nonblocking(ut->fd);
+       if (ret < 0)
+               close(ut->fd);
+       return ret;
 }
 
 static void udp_shutdown_targets(void)