*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
/** \file udp_send.c Para_server's udp sender. */
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
/** \file udp_send.c Para_server's udp sender. */
/** The opaque structure returned by vss_add_fec_client(). */
struct fec_client *fc;
/** The FEC parameters for this target. */
struct fec_client_parms fcp;
/** The opaque structure returned by vss_add_fec_client(). */
struct fec_client *fc;
/** The FEC parameters for this target. */
struct fec_client_parms fcp;
- if (sc->cq != NULL) {
- del_close_on_fork_list(sc->fd);
- cq_destroy(sc->cq);
- sc->cq = NULL;
- }
+ const char *buf;
+ size_t len;
+ struct udp_target *ut = sc->private_data;
+
+ 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) == len)
+ ut->sent_fec_eof = true;
-/** The maximal size of the per-target chunk queue. */
-#define UDP_CQ_BYTES 40000
-
-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);
- }
-}
-
static void udp_shutdown_targets(void)
{
struct sender_client *sc, *tmp;
static void udp_shutdown_targets(void)
{
struct sender_client *sc, *tmp;
list_for_each_entry_safe(sc, tmp, &targets, node)
list_for_each_entry_safe(sc, tmp, &targets, node)
/** Initialize UDP session and set maximum payload size. */
static int udp_init_fec(struct sender_client *sc)
{
/** Initialize UDP session and set maximum payload size. */
static int udp_init_fec(struct sender_client *sc)
{
mps = generic_max_transport_msg_size(sc->fd) - sizeof(struct udphdr);
PARA_INFO_LOG("current MPS = %d bytes\n", mps);
return mps;
mps = generic_max_transport_msg_size(sc->fd) - sizeof(struct udphdr);
PARA_INFO_LOG("current MPS = %d bytes\n", mps);
return mps;
- ret = send_queued_chunks(sc->fd, sc->cq);
- if (ret < 0)
- goto fail;
- if (!ret) { /* still data left in the queue */
- ret = cq_force_enqueue(sc->cq, buf, len);
- assert(ret >= 0);
- return 0;
- }
- ret = write_nonblock(sc->fd, buf, len);
+ ret = xwrite(sc->fd, buf, len);
if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED)) {
/*
* Happens if meanwhile an ICMP Destination / Port Unreachable
if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED)) {
/*
* Happens if meanwhile an ICMP Destination / Port Unreachable
ut->fcp.slices_per_group = scd->slices_per_group;
ut->fcp.data_slices_per_group = scd->data_slices_per_group;
ut->fcp.init_fec = udp_init_fec;
ut->fcp.send_fec = udp_send_fec;
ut->fcp.slices_per_group = scd->slices_per_group;
ut->fcp.data_slices_per_group = scd->data_slices_per_group;
ut->fcp.init_fec = udp_init_fec;
ut->fcp.send_fec = udp_send_fec;
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);
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);
- s->client_cmds[SENDER_ON] = udp_com_on;
- s->client_cmds[SENDER_OFF] = udp_com_off;
- s->client_cmds[SENDER_DENY] = NULL;
- s->client_cmds[SENDER_ALLOW] = NULL;
- s->client_cmds[SENDER_ADD] = udp_com_add;
- s->client_cmds[SENDER_DELETE] = udp_com_delete;
- sender_status = SENDER_OFF;
+ s->client_cmds[SENDER_on] = udp_com_on;
+ s->client_cmds[SENDER_off] = udp_com_off;
+ s->client_cmds[SENDER_deny] = NULL;
+ s->client_cmds[SENDER_allow] = NULL;
+ s->client_cmds[SENDER_add] = udp_com_add;
+ s->client_cmds[SENDER_delete] = udp_com_delete;
+ sender_status = SENDER_off;