* Changed 'number of worker threads' from a sysconfig.h #define to an actual
authorArt Cancro <ajc@citadel.org>
Thu, 4 Nov 1999 02:06:51 +0000 (02:06 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 4 Nov 1999 02:06:51 +0000 (02:06 +0000)
  server configuration setting.  Added it to the client .AS command.

citadel/citadel.h
citadel/config.c
citadel/control.c
citadel/routines2.c
citadel/sysconfig.h
citadel/sysdep.c

index e079dc58ba6859d4eaced3fa47ddfdb1b790de45..88759d591deaf8b519ef9783d538341356dfb516 100644 (file)
@@ -76,7 +76,8 @@ struct config {
        char c_logpages[ROOMNAMELEN];   /* Room to log pages to (or not)    */
        char c_createax;                /* Axlevel required to create rooms */
        long c_maxmsglen;               /* Maximum message length           */
-       };
+       int c_worker_threads;           /* Number of worker threads to start*/
+};
 
 #define NODENAME               config.c_nodename
 #define FQDN                   config.c_fqdn
index a9ad7f7115f16551ccd41cad69b9995e9fbd0b79..3b81fec3f1fcb67fbf64ba28ac1759a722a9c2da 100644 (file)
@@ -78,6 +78,14 @@ void get_config(void) {
                 config.c_maxmsglen = INT_MAX;
         if (config.c_maxmsglen < 8192)
                 config.c_maxmsglen = 8192;
+
+        /* Default number of worker threads is 15 and the minimum is 5
+         */
+       /* Can't have fewer than two worker threads */
+       if (config.c_worker_threads == 0)
+               config.c_worker_threads = 15;
+       if (config.c_worker_threads < 5)
+               config.c_worker_threads = 5;
                
 }
 
index e71c5bbe652a1c66144a509d534ac9440144f57c..2f1302fa3d8c37a59105025a7812270ca6dda3d3 100644 (file)
@@ -161,6 +161,7 @@ void cmd_conf(char *argbuf) {
                cprintf("%s\n", config.c_logpages);
                cprintf("%d\n", config.c_createax);
                cprintf("%d\n", config.c_maxmsglen);
+               cprintf("%d\n", config.c_worker_threads);
                cprintf("000\n");
                }
 
@@ -236,6 +237,8 @@ void cmd_conf(char *argbuf) {
                        case 20: if (atoi(buf) >= 8192)
                                        config.c_maxmsglen = atoi(buf);
                                break;
+                       case 21: if (atoi(buf) >= 2)
+                                       config.c_worker_threads = atoi(buf);
                        }
                    ++a;
                    }
index 77f740b5c4c92940cf2e8a6233fabab8c17d399e..c903a756b7f280b8f37b86de22e7f42b88ee76b8 100644 (file)
@@ -624,7 +624,7 @@ void read_bio(void)
 void do_system_configuration(void)
 {
        char buf[256];
-       char sc[21][256];
+       char sc[22][256];
        int expire_mode = 0;
        int expire_value = 0;
        int a;
@@ -638,7 +638,7 @@ void do_system_configuration(void)
        if (buf[0] == '1') {
                a = 0;
                while (serv_gets(buf), strcmp(buf, "000")) {
-                       if (a < 21)
+                       if (a < 22)
                                strcpy(&sc[a][0], buf);
                        ++a;
                }
@@ -688,6 +688,7 @@ void do_system_configuration(void)
        strprompt("Default room purge time (days)", &sc[17][0], 5);
        strprompt("Name of room to log pages", &sc[18][0], ROOMNAMELEN);
        strprompt("Maximum message length", &sc[20][0], 20);
+       strprompt("Number of worker threads", &sc[21][0], 3);
 
        /* Angels and demons dancing in my head... */
        do {
@@ -720,7 +721,7 @@ void do_system_configuration(void)
                serv_puts("CONF set");
                serv_gets(buf);
                if (buf[0] == '4') {
-                       for (a = 0; a < 21; ++a)
+                       for (a = 0; a < 22; ++a)
                                serv_puts(&sc[a][0]);
                        serv_puts("000");
                }
index ff875ee394f2ab4cc52e42c349618b0f62b4c91b..10796413d7195ac68062fb01712219133ca99eca 100644 (file)
  */
 #define HOUSEKEEPING_WAKEUP    60
 
-/*
- * We'll almost certainly want to do this more elegantly.  For now we are
- * creating a fixed-size pool of worker threads.
- */
-#define NUM_WORKER_THREADS     15
-
 
 /*** STRUCTURE SIZE VARIABLES ***/
 
index 9afd43fec24072d8196f4c969f9d04662e6a2fca..333319b9cfcec0c262cee6bd957ccd1027276761 100644 (file)
@@ -813,7 +813,7 @@ int main(int argc, char **argv)
        /*
         * Now create a bunch of worker threads.
         */
-       for (i=0; i<(NUM_WORKER_THREADS-1); ++i) {
+       for (i=0; i<(config.c_worker_threads-1); ++i) {
                pthread_attr_init(&attr);
                        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
                if (pthread_create(&HousekeepingThread, &attr,