Merge branch 'maint'
[paraslash.git] / recv_common.c
index a5689390987ac9c9b063dad200653e990268824e..bbaf139688ff6ccb0d78284f1bb495e7dd106a86 100644 (file)
@@ -7,6 +7,7 @@
 /** \file recv_common.c common functions of para_recv and para_audiod */
 
 #include <regex.h>
+#include <stdbool.h>
 
 #include "para.h"
 #include "list.h"
@@ -14,6 +15,7 @@
 #include "ggo.h"
 #include "recv.h"
 #include "string.h"
+#include "buffer_tree.h"
 
 DEFINE_RECEIVER_ARRAY;
 
@@ -45,14 +47,13 @@ static void *parse_receiver_args(int receiver_num, char *options)
                        return NULL;
                for (i = argc - 1; i >= 0; i--)
                        argv[i + 1] = argv[i];
-               argv[0] = NULL;
                argc++;
        } else {
                argc = 1;
                argv = para_malloc(2 * sizeof(char*));
-               argv[0] = NULL;
                argv[1] = NULL;
        }
+       argv[0] = make_message("%s_recv", r->name);
        conf = r->parse_config(argc, argv);
        for (i = 1; i < argc; i++)
                free(argv[i]);
@@ -121,3 +122,16 @@ void print_receiver_helps(int detailed)
                ggo_print_help(&r->help, detailed);
        }
 }
+
+int generic_recv_pre_select(struct sched *s, struct task *t)
+{
+       struct receiver_node *rn = container_of(t, struct receiver_node, task);
+       int ret = btr_node_status(rn->btrn, 0, BTR_NT_ROOT);
+
+       t->error = 0;
+       if (ret < 0) {
+               s->timeout.tv_sec = 0;
+               s->timeout.tv_usec = 1;
+       }
+       return ret;
+}