First draft of the dccp sender/receiver pair.
[paraslash.git] / server.c
index c46966e..67d9bce 100644 (file)
--- a/server.c
+++ b/server.c
@@ -56,6 +56,7 @@ struct misc_meta_data *mmd;
 */
 struct gengetopt_args_info conf;
 char *user_list = NULL;
+extern void dccp_send_init(struct sender *);
 extern void http_send_init(struct sender *);
 extern void ortp_send_init(struct sender *);
 extern struct audio_format afl[];
@@ -94,6 +95,10 @@ struct sender senders[] = {
                .name = "http",
                .init = http_send_init,
        },
+       {
+               .name = "dccp",
+               .init = dccp_send_init,
+       },
 #ifdef HAVE_ORTP
        {
                .name = "ortp",
@@ -278,41 +283,25 @@ static void setup_signal_handling(void)
 
 static void init_dbtool(void)
 {
-       int i;
+       int i, ret;
 
        mmd->dbt_change = -1; /* no change nec., set to new dbt num by com_cdt */
-       if (!dblist[1].name)
+       if (!conf.dbtool_given)
                goto random;
-       if (conf.dbtool_given) {
-               for (i = 0; dblist[i].name; i++) {
-                       if (strcmp(dblist[i].name, conf.dbtool_arg))
-                               continue;
-                       PARA_NOTICE_LOG("initializing %s database tool\n",
-                               dblist[i].name);
-                       if (dblist[i].init(&dblist[i]) < 0) {
-                               PARA_WARNING_LOG("init %s failed",
-                                       dblist[i].name);
-                               goto random;
-                       }
-                       mmd->dbt_num = i;
-                       return;
-               }
-               PARA_WARNING_LOG("%s", "no such dbtool, switching to random\n");
-               goto random;
-       }
-       /* use the first dbtool that works
-        * (assuming that random always works)
-        */
-       for (i = 1; dblist[i].name; i++) {
-               int ret = dblist[i].init(&dblist[i]);
-               if (ret >= 0) {
-                       PARA_INFO_LOG("initialized %s\n", dblist[i].name);
-                       mmd->dbt_num = i;
-                       return;
+       for (i = 0; dblist[i].name; i++) {
+               if (strcmp(dblist[i].name, conf.dbtool_arg))
+                       continue;
+               PARA_NOTICE_LOG("initializing %s database tool\n",
+                       dblist[i].name);
+               ret = dblist[i].init(&dblist[i]);
+               if (ret < 0) {
+                       PARA_WARNING_LOG("%s", PARA_STRERROR(-ret));
+                       break;
                }
-               PARA_CRIT_LOG("%s init failed: %s\n", dblist[i].name,
-                       PARA_STRERROR(-ret));
+               mmd->dbt_num = i;
+               return;
        }
+       PARA_WARNING_LOG("%s", "falling back to the random dbtool\n");
 random:
        mmd->dbt_num = 0;
        dblist[0].init(&dblist[0]); /* always successful */
@@ -332,7 +321,7 @@ static void init_random_seed(void)
        int fd, ret = -1, len = sizeof(unsigned int);
        unsigned int seed;
 
-       fd = open("/dev/random", O_RDONLY);
+       fd = open("/dev/urandom", O_RDONLY);
        if (fd < 0)
                goto out;
        ret = -2;