#define UDP_RECV_ERRORS \
PARA_ERROR(UDP_SYNTAX, "udp_recv syntax error"), \
PARA_ERROR(UDP_OVERRUN, "output buffer overrun"), \
+ PARA_ERROR(UDP_TIMEOUT, "timeout reading on UDP socket"), \
#define HTTP_RECV_ERRORS \
/** 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)
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)
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 */
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);