simplify writer node group
[paraslash.git] / file_writer.c
index 9145ef9..4a2e048 100644 (file)
@@ -68,42 +68,38 @@ static int file_writer_write(char *data, size_t nbytes, struct writer_node *wn)
        return ret;
 }
 
-static void file_writer_pre_select(struct sched *s, struct task *t)
+static int file_writer_pre_select(struct sched *s, struct writer_node *wn)
 {
-       struct writer_node *wn = t->private_data;
        struct private_file_writer_data *pfwd = wn->private_data;
        struct writer_node_group *wng = wn->wng;
 
-//     PARA_INFO_LOG("task %p check_fd: %d\n", t, pfwd->check_fd);
        pfwd->check_fd = 0;
-       t->ret = -E_FW_NO_FILE;
        if (pfwd->fd <= 0)
-               return;
-       t->ret = 0;
+               return -E_FW_NO_FILE;
        if (!*wng->loaded)
-               return;
-       t->ret = 1;
+               return 1;
        para_fd_set(pfwd->fd, &s->wfds, &s->max_fileno);
        pfwd->check_fd = 1;
+       return 1;
 }
 
-static void file_writer_post_select(struct sched *s, struct task *t)
+static int file_writer_post_select(struct sched *s, struct writer_node *wn)
 {
-       struct writer_node *wn = t->private_data;
        struct private_file_writer_data *pfwd = wn->private_data;
        struct writer_node_group *wng = wn->wng;
+       int ret = 0;
 
-       t->ret = 0;
        if (!pfwd->check_fd)
-               return;
+               return 0;
        if (!*wng->loaded)
-               return;
+               return 0;
        if (!FD_ISSET(pfwd->fd, &s->wfds))
-               return;
+               return 0;
 //     PARA_INFO_LOG("writing %zd\n", *wng->loaded);
-       t->ret = write(pfwd->fd, wng->buf, *wng->loaded);
-       if (t->ret < 0)
-               t->ret = -E_FW_WRITE;
+       ret = write(pfwd->fd, wng->buf, *wng->loaded);
+       if (ret < 0)
+               ret = -E_FW_WRITE;
+       return ret;
 }
 
 static void file_writer_close(struct writer_node *wn)