]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - udp_recv.c
RC4: Allocate 8 extra bytes for send buffer.
[paraslash.git] / udp_recv.c
index 4f363ccb7f15b65273867526dcd43e9a98337b9c..00ad3e2781745c2e04af80dc462b75171e380dd0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -32,7 +32,6 @@ 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)
@@ -78,20 +77,16 @@ 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)) {
-               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;
+       if (!FD_ISSET(purd->fd, &s->rfds))
                return;
-       }
        iovcnt = btr_pool_get_buffers(purd->btrp, iov);
        ret = -E_UDP_OVERRUN;
        if (iovcnt == 0)
                goto err;
        ret = para_readv(purd->fd, iov, iovcnt);
+       /* EAGAIN is possible even if FD_ISSET */
+       if (ret < 0 && is_errno(-ret, EAGAIN))
+               return;
        if (ret == 0)
                ret = -E_RECV_EOF;
        if (ret < 0)
@@ -100,7 +95,6 @@ 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 */
@@ -229,7 +223,6 @@ 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);