]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - udp_send.c
udp_send: Add/remove the udp socket fd only once.
[paraslash.git] / udp_send.c
index 880c83cf1078a5553880897466ec43bccb09bedf..ba7163a8dcdbcffcc9f60772a7d34c5f3c0aec28 100644 (file)
@@ -57,7 +57,6 @@ static int sender_status;
 static void udp_close_target(struct sender_client *sc)
 {
        if (sc->cq != NULL) {
-               del_close_on_fork_list(sc->fd);
                cq_destroy(sc->cq);
                sc->cq = NULL;
        }
@@ -69,6 +68,8 @@ static void udp_delete_target(struct sender_client *sc, const char *msg)
 
        PARA_NOTICE_LOG("deleting %s (%s) from list\n", sc->name, msg);
        udp_close_target(sc);
+       close(sc->fd);
+       del_close_on_fork_list(sc->fd);
        vss_del_fec_client(ut->fc);
        list_del(&sc->node);
        free(sc->name);
@@ -159,7 +160,6 @@ static void udp_init_session(struct sender_client *sc)
 {
        if (sc->cq == NULL) {
                sc->cq = cq_new(UDP_CQ_BYTES);
-               add_close_on_fork_list(sc->fd);
                PARA_NOTICE_LOG("sending to udp %s\n", sc->name);
        }
 }
@@ -342,7 +342,6 @@ static int udp_com_add(struct sender_command_data *scd)
        sc = ut->sc = para_calloc(sizeof(*sc));
        ut->fcp.slices_per_group      = scd->slices_per_group;
        ut->fcp.data_slices_per_group = scd->data_slices_per_group;
-       ut->fcp.max_slice_bytes       = scd->max_slice_bytes;
        ut->fcp.init_fec              = udp_init_fec;
        ut->fcp.send_fec              = udp_send_fec;
 
@@ -363,6 +362,7 @@ static int udp_com_add(struct sender_command_data *scd)
        PARA_INFO_LOG("adding to target list (%s)\n", sc->name);
        ut->fc = vss_add_fec_client(sc, &ut->fcp);
        para_list_add(&sc->node, &targets);
+       add_close_on_fork_list(sc->fd);
        return 1;
 err:
        if (sc->fd >= 0)
@@ -381,9 +381,8 @@ static char *udp_info(void)
 
        list_for_each_entry(sc, &targets, node) {
                struct udp_target *ut = sc->private_data;
-               char *tmp = make_message("%s%s/%u:%u:%u ",
+               char *tmp = make_message("%s%s/%u:%u ",
                        tgts ? : "", sc->name,
-                       ut->fcp.max_slice_bytes,
                        ut->fcp.data_slices_per_group,
                        ut->fcp.slices_per_group
                );
@@ -422,11 +421,12 @@ static char *udp_help(void)
 {
        return make_message(
                "usage: {on|off}\n"
-               "usage: {add|delete} host[:port][/packet_size:k:n]\n"
+               "usage: {add|delete} ip_address[:port][/[packet_size:]k:n]\n"
+               "       - k is the number of data slices per FEC group\n"
+               "       - n is the total number of slices in a FEC group\n"
+               "       - packet_size reduces the slice size below path MTU\n\n"
                "examples: add 224.0.1.38:1500  (IPv4 multicast)\n"
-               "          add 224.0.1.38:1500/1400:14:16\n"
-               "              (likewise, using 1400 byte packets, with 14\n"
-               "               data slices per 16 slice FEC group)\n"
+               "          add 224.0.1.38:8080/14:16 (explicit FEC)\n"
                "          add 10.10.1.42       (using default port)\n"
                "          add [FF05::42]:1500  (IPv6 multicast)\n"
                "          add [::1]            (IPv6 localhost/default port)\n"