X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=server.c;h=a6fca8b6cd5629777ad347e9a20050611aa41895;hb=c5517c98d28a74a89086b0641e3633d16eaf9df7;hp=71ee9eb6321b7b34e9c61b0a9bd9389aa391f65f;hpb=2ed89c59f0efcd0a2763f47c7d3455663241e623;p=paraslash.git diff --git a/server.c b/server.c index 71ee9eb6..a6fca8b6 100644 --- a/server.c +++ b/server.c @@ -63,15 +63,24 @@ extern struct audio_format afl[]; /** the list of supported database tools */ struct dbtool dblist[] = { { - .name = "dopey", - .init = dopey_dbtool_init, + .name = "random", + .init = random_dbtool_init, .update_audio_file = NULL, }, + { + .name = "plm", + .init = plm_dbtool_init, + .update_audio_file = NULL, + .pre_select = NULL, + .post_select = NULL, + }, #ifdef HAVE_MYSQL { .name = "mysql", .init = mysql_dbtool_init, .update_audio_file = NULL, + .pre_select = NULL, + .post_select = NULL, }, #endif { @@ -288,9 +297,9 @@ static void setup_signal_handling(void) ret += para_install_sighandler(SIGTERM); ret += para_install_sighandler(SIGHUP); ret += para_install_sighandler(SIGCHLD); + ret += para_install_sighandler(SIGUSR1); signal(SIGPIPE, SIG_IGN); - signal(SIGUSR1, SIG_IGN); - if (ret != 4) { + if (ret != 5) { PARA_EMERG_LOG("%s", "could not install signal handlers\n"); exit(EXIT_FAILURE); } @@ -302,7 +311,7 @@ static void init_dbtool(void) mmd->dbt_change = -1; /* no change nec., set to new dbt num by com_cdt */ if (!dblist[1].name) - goto dopey; + goto random; if (conf.dbtool_given) { for (i = 0; dblist[i].name; i++) { if (strcmp(dblist[i].name, conf.dbtool_arg)) @@ -312,16 +321,16 @@ static void init_dbtool(void) if (dblist[i].init(&dblist[i]) < 0) { PARA_WARNING_LOG("init %s failed", dblist[i].name); - goto dopey; + goto random; } mmd->dbt_num = i; return; } - PARA_WARNING_LOG("%s", "no such dbtool, switching to dopey\n"); - goto dopey; + PARA_WARNING_LOG("%s", "no such dbtool, switching to random\n"); + goto random; } /* use the first dbtool that works - * (assuming that dopey always works) + * (assuming that random always works) */ for (i = 1; dblist[i].name; i++) { int ret = dblist[i].init(&dblist[i]); @@ -333,7 +342,7 @@ static void init_dbtool(void) PARA_CRIT_LOG("%s init failed: %s\n", dblist[i].name, PARA_STRERROR(-ret)); } -dopey: +random: mmd->dbt_num = 0; dblist[0].init(&dblist[0]); /* always successful */ } @@ -417,7 +426,7 @@ static void handle_dbt_change(void) return; } /* init failed */ - PARA_ERROR_LOG("%s -- switching to dopey\n", PARA_STRERROR(-ret)); + PARA_ERROR_LOG("%s -- switching to the random dbtool\n", PARA_STRERROR(-ret)); dblist[0].init(&dblist[0]); mmd->dbt_num = 0; } @@ -494,6 +503,10 @@ repeat: &max_fileno, &rfds, &wfds); } + if (dblist[mmd->dbt_num].pre_select) { + ret = dblist[mmd->dbt_num].pre_select(&rfds, &wfds); + max_fileno = MAX(max_fileno, ret); + } mmd_unlock(); // PARA_DEBUG_LOG("%s: select (max = %i)\n", __func__, max_fileno); ret = select(max_fileno + 1, &rfds, &wfds, NULL, timeout); @@ -502,6 +515,8 @@ repeat: mmd_lock(); if (mmd->dbt_change >= 0) handle_dbt_change(); + if (dblist[mmd->dbt_num].post_select) + dblist[mmd->dbt_num].post_select(&rfds, &wfds); if (ret < 0 && err == EINTR) goto repeat; if (ret < 0) {