X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=udp_recv.c;h=f98a9664aec2d1ee3d8129e70442468423fa79a8;hb=refs%2Fheads%2Fnext;hp=4620d61a4603e46561881a3b7c0976a09c7788d9;hpb=9d24300965cbcdfddb9f63b6bc8018da50d7d8e1;p=paraslash.git diff --git a/udp_recv.c b/udp_recv.c index 4620d61a..f98a9664 100644 --- a/udp_recv.c +++ b/udp_recv.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2005 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2005 Andre Noll , see file COPYING. */ /** \file udp_recv.c Paraslash's udp receiver */ #include @@ -27,13 +23,13 @@ #include "net.h" #include "fd.h" -static void udp_recv_pre_select(struct sched *s, void *context) +static void udp_recv_pre_monitor(struct sched *s, void *context) { struct receiver_node *rn = context; - if (generic_recv_pre_select(s, rn) <= 0) + if (generic_recv_pre_monitor(s, rn) <= 0) return; - para_fd_set(rn->fd, &s->rfds, &s->max_fileno); + sched_monitor_readfd(rn->fd, s); } static int udp_check_eof(size_t sz, struct iovec iov[2]) @@ -44,17 +40,17 @@ static int udp_check_eof(size_t sz, struct iovec iov[2]) if (memcmp(iov[0].iov_base, FEC_EOF_PACKET, FEC_EOF_PACKET_LEN) != 0) return 0; - return -E_RECV_EOF; + return -E_EOF; } if (memcmp(iov[0].iov_base, FEC_EOF_PACKET, iov[0].iov_len) != 0) return 0; if (memcmp(iov[1].iov_base, &FEC_EOF_PACKET[iov[0].iov_len], FEC_EOF_PACKET_LEN - iov[0].iov_len) != 0) return 0; - return -E_RECV_EOF; + return -E_EOF; } -static int udp_recv_post_select(__a_unused struct sched *s, void *context) +static int udp_recv_post_monitor(__a_unused struct sched *s, void *context) { struct receiver_node *rn = context; struct btr_node *btrn = rn->btrn; @@ -72,7 +68,7 @@ static int udp_recv_post_select(__a_unused struct sched *s, void *context) ret = -E_UDP_OVERRUN; if (iovcnt == 0) goto out; - ret = readv_nonblock(rn->fd, iov, iovcnt, &s->rfds, &num_bytes); + ret = readv_nonblock(rn->fd, iov, iovcnt, &num_bytes); if (num_bytes == 0) goto out; readv_ret = ret; @@ -172,7 +168,7 @@ static int udp_recv_open(struct receiver_node *rn) uint32_t port = RECV_CMD_OPT_UINT32_VAL(UDP, PORT, lpr); int ret; - ret = makesock(IPPROTO_UDP, 1, host, port, NULL); + ret = makesock(IPPROTO_UDP, true /* passive */, host, port, NULL); if (ret < 0) return ret; rn->fd = ret; @@ -190,10 +186,9 @@ err: return ret; } -/** See \ref recv_init(). */ const struct receiver lsg_recv_cmd_com_udp_user_data = { .open = udp_recv_open, .close = udp_recv_close, - .pre_select = udp_recv_pre_select, - .post_select = udp_recv_post_select, + .pre_monitor = udp_recv_pre_monitor, + .post_monitor = udp_recv_post_monitor, };