]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
udp: integrate resolve hook
authorGerrit Renker <grenker@cscs.ch>
Sun, 13 Jun 2010 09:30:47 +0000 (11:30 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 22 Jun 2010 23:16:43 +0000 (01:16 +0200)
This integrates the new resolve hook into the UDP sender; exploiting the
invariant that the 'port' of sender_command_data structure is now always set.

It further reuses the new resolve_target() function for the pre-configured
sender targets. This is necessary to unify the syntax (otherwise the
server.conf would have to be limited to IP-addresses only), and allows to
use hostnames in the server configuration file.

The worst case that can here be anticipated is that unresolvable targets are
specified in server.conf. In this case the server hangs for circa 20 seconds
per unresolvable target, and then concludes with error messages such as:

 (8355) init_vss_task: initializing udp sender
 ...
 (8355) udp_add_target: adding to target list (10.0.0.2:8000)
 (8355) makesock: can not resolve UDP address funzt.net#8000: Name or service not known.
 (8355) udp_init_target_list: not adding requested target 'funzt.net'
 (8355) makesock: can not resolve UDP address funzt.also.net#8000: Name or service not known.
 (8355) udp_init_target_list: not adding requested target 'funzt.also.net'
 (8355) udp_send_init: udp sender init complete

udp_send.c

index adac6a8db1e8e66bb2e68441c870390f59756324..b542f5a9534fe73953f49ff73e2f62eedc2f05bd 100644 (file)
@@ -324,12 +324,9 @@ fail:
 
 static void udp_add_target(struct sender_command_data *scd)
 {
-       int ret, port = scd->port > 0 ? scd->port : conf.udp_default_port_arg;
+       int ret;
        struct udp_target *ut = para_calloc(sizeof(*ut));
 
-       strncpy(ut->host, scd->host, sizeof(ut->host));
-       ut->port = scd->port > 0 ? scd->port : conf.udp_default_port_arg;
-
        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;
@@ -339,7 +336,7 @@ static void udp_add_target(struct sender_command_data *scd)
        ut->sc = para_calloc(sizeof(*ut->sc));
        ut->sc->private_data = ut;
        ut->sc->fd = -1;
-       ret = para_connect_simple(IPPROTO_UDP, scd->host, port);
+       ret = para_connect_simple(IPPROTO_UDP, scd->host, scd->port);
        if (ret < 0)
                goto err;
        ut->sc->fd = ret;
@@ -357,8 +354,8 @@ static void udp_add_target(struct sender_command_data *scd)
 err:
        if (ut->sc->fd >= 0)
                close(ut->sc->fd);
-       PARA_NOTICE_LOG("failed to set up %s#%d (%s)- not adding it\n",
-               scd->host, port, para_strerror(-ret));
+       PARA_NOTICE_LOG("failed to set up %s:%d (%s)- not adding it\n",
+                       scd->host, scd->port, para_strerror(-ret));
        free(ut->sc);
        free(ut);
 }
@@ -407,12 +404,11 @@ static void udp_init_target_list(void)
 
        INIT_LIST_HEAD(&targets);
        for (i = 0; i < conf.udp_target_given; i++) {
-               if (parse_fec_url(conf.udp_target_arg[i], &scd) < 0) {
-                       PARA_CRIT_LOG("syntax error for udp target option "
-                               "#%d, ignoring\n", i);
-                       continue;
-               }
-               udp_add_target(&scd);
+               if (udp_resolve_target(conf.udp_target_arg[i], &scd) < 0)
+                       PARA_CRIT_LOG("not adding requested target '%s'\n",
+                                       conf.udp_target_arg[i]);
+               else
+                       udp_add_target(&scd);
        }
 }