X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=udp_send.c;h=e80670d0f3866dcde32114c0459a506b8cb78cff;hp=8677ec5eeea4c17fcd0a5b9f7918fc47ea961c35;hb=f16b28109fe2f4a7caf83350fff8bfcfe73b7b6c;hpb=91edaa02c232edf82b93a928058c044df80badc1 diff --git a/udp_send.c b/udp_send.c index 8677ec5e..e80670d0 100644 --- a/udp_send.c +++ b/udp_send.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2009 Andre Noll + * Copyright (C) 2005-2010 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -7,10 +7,12 @@ /** \file udp_send.c Para_server's udp sender. */ +#include #include #include #include #include +#include #include "server.cmdline.h" #include "para.h" @@ -158,7 +160,7 @@ static int udp_init_session(struct udp_target *ut) if (ut->fd >= 0) /* nothing to do */ return 0; - ret = makesock(AF_UNSPEC, IPPROTO_UDP, 0, ut->host, ut->port); + ret = para_connect_simple(IPPROTO_UDP, ut->host, ut->port); if (ret < 0) return ret; ut->fd = ret; @@ -190,11 +192,13 @@ static void udp_shutdown_targets(void) size_t len = 0; /* STFU, gcc */ list_for_each_entry_safe(ut, tmp, &targets, node) { + int ubuntu_glibc_headers_suck; if (ut->fd < 0) continue; if (!buf) len = vss_get_fec_eof_packet(&buf); - write(ut->fd, buf, len); + /* ignore return value, we're closing the target anyway. */ + ubuntu_glibc_headers_suck = write(ut->fd, buf, len); /* STFU */ udp_close_target(ut); } } @@ -238,22 +242,24 @@ static int udp_send_fec(char *buf, size_t len, void *private_data) if (ret < 0) goto fail; ret = send_queued_chunks(ut->fd, ut->cq, 0); + if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED)) + ret = 0; if (ret < 0) goto fail; if (!len) return 0; if (!ret) { /* still data left in the queue */ - ret = cq_enqueue(ut->cq, buf, len); - if (ret < 0) - goto fail; + ret = cq_force_enqueue(ut->cq, buf, len); + assert(ret >= 0); } ret = write_nonblock(ut->fd, buf, len, 0); + if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED)) + ret = 0; if (ret < 0) goto fail; if (ret != len) { - ret = cq_enqueue(ut->cq, buf + ret, len - ret); - if (ret < 0) - goto fail; + ret = cq_force_enqueue(ut->cq, buf + ret, len - ret); + assert(ret >= 0); } return 1; fail: @@ -304,10 +310,10 @@ static char *udp_info(void) ret = make_message( "udp sender:\n" "\tstatus: %s\n" - "\tport: udp %d\n" + "\tport: %s\n" "\ttargets: %s\n", (sender_status == SENDER_ON)? "on" : "off", - conf.udp_default_port_arg, + stringify_port(conf.udp_default_port_arg, "udp"), tgts? tgts : "(none)" ); free(tgts);