convert para_audiod to the new scheduler.
[paraslash.git] / dccp_recv.c
index f7db6fc..deca716 100644 (file)
 #include "para.h"
 #include "error.h"
 #include "dccp.h"
+#include "list.h"
+#include "sched.h"
 #include "recv.h"
 #include "string.h"
 #include "net.h"
+#include "fd.h"
 
 #include "dccp_recv.cmdline.h"
 
@@ -116,35 +119,35 @@ static void *dccp_recv_parse_config(int argc, char **argv)
        return NULL;
 }
 
-static int dccp_recv_pre_select(struct receiver_node *rn, fd_set *rfds,
-               __a_unused fd_set *wfds, __a_unused struct timeval *timeout)
+static void dccp_recv_pre_select(struct sched *s, struct task *t)
 {
-       struct private_dccp_recv_data *pdd = rn->private_data;
+       struct private_dccp_recv_data *pdd = t->private_data;
 
        if (!pdd)
-               return -1;
-       FD_SET(pdd->fd, rfds);
-       return pdd->fd;
+               return ;
+       para_fd_set(pdd->fd, &s->rfds, &s->max_fileno);
 }
 
-static int dccp_recv_post_select(struct receiver_node *rn, int select_ret,
-               fd_set *rfds, __a_unused fd_set *wfds)
+static void dccp_recv_post_select(struct sched *s, struct task *t)
 {
-       int ret;
+       struct receiver_node *rn = t->private_data;
        struct private_dccp_recv_data *pdd = rn->private_data;
 
-       if (!select_ret || !pdd || !FD_ISSET(pdd->fd, rfds))
-               return 1; /* nothing to do */
+       t->ret = 1;
+       if (!s->select_ret || !pdd || !FD_ISSET(pdd->fd, &s->rfds))
+               return; /* nothing to do */
+       t->ret = -E_DCCP_OVERRUN;
        if (rn->loaded >= DCCP_BUFSIZE)
-               return -E_DCCP_OVERRUN;
-       ret = recv_bin_buffer(pdd->fd, rn->buf + rn->loaded,
+               return;
+       t->ret = recv_bin_buffer(pdd->fd, rn->buf + rn->loaded,
                DCCP_BUFSIZE - rn->loaded);
-       if (ret <= 0) {
-               PARA_INFO_LOG("%s\n", ret? PARA_STRERROR(-ret) : "eof");
-               return ret;
+       if (t->ret <= 0) {
+               rn->eof = 1;
+               if (!t->ret)
+                       t->ret = -E_DCCP_RECV_EOF;
+               return;
        }
-       rn->loaded += ret;
-       return 1;
+       rn->loaded += t->ret;
 }
 
 /**