X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=udp_send.c;h=2eb33b537606725dd71f1ddc4bb531814c659c7d;hb=746cf9c9c89b8b0c6f39b8ec3f07a0386e61a8ae;hp=bbc38f0117d796ac5211bf86821244daf17baf84;hpb=6aad8ed5fef24cdf2c65cbb193572cb10c2b2c1c;p=paraslash.git diff --git a/udp_send.c b/udp_send.c index bbc38f01..2eb33b53 100644 --- a/udp_send.c +++ b/udp_send.c @@ -46,6 +46,8 @@ struct udp_target { struct fec_client *fc; /** The FEC parameters for this target. */ struct fec_client_parms fcp; + /** Whether we already sent the FEC eof packet to this target. */ + bool sent_fec_eof; }; static struct list_head targets; @@ -54,15 +56,17 @@ static int sender_status; static void udp_close_target(struct sender_client *sc) { const char *buf; - size_t len = vss_get_fec_eof_packet(&buf); + size_t len; + struct udp_target *ut = sc->private_data; - /* - * Ignore the return value of write() since we are closing the target - * anyway. The sole purpose of the "do_nothing" statement is to silence - * gcc. - */ + if (ut->sent_fec_eof) + return; + PARA_NOTICE_LOG("sending FEC EOF\n"); + len = vss_get_fec_eof_packet(&buf); + /* Ignore write() errors since we are closing the target anyway. */ if (write(sc->fd, buf, len)) - do_nothing; + do_nothing; /* avoid "ignoring return value" warning */ + ut->sent_fec_eof = true; } static void udp_delete_target(struct sender_client *sc, const char *msg) @@ -232,9 +236,11 @@ static int udp_com_delete(struct sender_command_data *scd) /** Initialize UDP session and set maximum payload size. */ static int udp_init_fec(struct sender_client *sc) { + struct udp_target *ut = sc->private_data; int mps; PARA_NOTICE_LOG("sending to udp %s\n", sc->name); + ut->sent_fec_eof = false; mps = generic_max_transport_msg_size(sc->fd) - sizeof(struct udphdr); PARA_INFO_LOG("current MPS = %d bytes\n", mps); return mps;