From: Gerrit Renker Date: Sun, 13 Jun 2010 09:30:47 +0000 (+0200) Subject: udp: integrate resolve hook X-Git-Tag: v0.4.3~8^2~4 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=3a3a63b6b6a420637ecf89e065947965a7fec685;p=paraslash.git udp: integrate resolve hook 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 --- diff --git a/udp_send.c b/udp_send.c index adac6a8d..b542f5a9 100644 --- a/udp_send.c +++ b/udp_send.c @@ -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); } }