X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=udp_recv.c;h=4f363ccb7f15b65273867526dcd43e9a98337b9c;hb=4d4379901a0a01859728d56795a7ab6ada9c876b;hp=8dc8edc0a3c9588492a47a5d6389236c601dbdbd;hpb=85c25aaa851aa20aba167b0fa5c827d115079681;p=paraslash.git diff --git a/udp_recv.c b/udp_recv.c index 8dc8edc0..4f363ccb 100644 --- a/udp_recv.c +++ b/udp_recv.c @@ -32,6 +32,7 @@ struct private_udp_recv_data { /** The socket file descriptor. */ int fd; struct btr_pool *btrp; + struct timeval last_read_time; }; static void udp_recv_pre_select(struct sched *s, struct task *t) @@ -77,8 +78,15 @@ static void udp_recv_post_select(__a_unused struct sched *s, struct task *t) goto err; if (ret == 0) return; - if (!FD_ISSET(purd->fd, &s->rfds)) + if (!FD_ISSET(purd->fd, &s->rfds)) { + struct timeval tmp; + tv_add(&purd->last_read_time, &(struct timeval)EMBRACE(5, 0), + &tmp); + ret = -E_UDP_TIMEOUT; + if (tv_diff(now, &tmp, NULL) > 0) + goto err; return; + } iovcnt = btr_pool_get_buffers(purd->btrp, iov); ret = -E_UDP_OVERRUN; if (iovcnt == 0) @@ -92,6 +100,7 @@ static void udp_recv_post_select(__a_unused struct sched *s, struct task *t) ret = udp_check_eof(packet_size, iov); if (ret < 0) goto err; + purd->last_read_time = *now; if (iov[0].iov_len >= packet_size) btr_add_output_pool(purd->btrp, packet_size, btrn); else { /* both buffers contain data */ @@ -220,6 +229,7 @@ static int udp_recv_open(struct receiver_node *rn) PARA_INFO_LOG("receiving from %s:%d, fd=%d\n", c->host_arg, c->port_arg, purd->fd); purd->btrp = btr_pool_new("udp_recv", 320 * 1024); + purd->last_read_time = *now; return purd->fd; err: free(rn->private_data);