From 5adb1c1c9e550d63bc95741027be1ee0825a8e0a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 4 Nov 1999 02:06:51 +0000 Subject: [PATCH] * Changed 'number of worker threads' from a sysconfig.h #define to an actual server configuration setting. Added it to the client .AS command. --- citadel/citadel.h | 3 ++- citadel/config.c | 8 ++++++++ citadel/control.c | 3 +++ citadel/routines2.c | 7 ++++--- citadel/sysconfig.h | 6 ------ citadel/sysdep.c | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/citadel/citadel.h b/citadel/citadel.h index e079dc58b..88759d591 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -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 diff --git a/citadel/config.c b/citadel/config.c index a9ad7f711..3b81fec3f 100644 --- a/citadel/config.c +++ b/citadel/config.c @@ -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; } diff --git a/citadel/control.c b/citadel/control.c index e71c5bbe6..2f1302fa3 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -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; } diff --git a/citadel/routines2.c b/citadel/routines2.c index 77f740b5c..c903a756b 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -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"); } diff --git a/citadel/sysconfig.h b/citadel/sysconfig.h index ff875ee39..10796413d 100644 --- a/citadel/sysconfig.h +++ b/citadel/sysconfig.h @@ -67,12 +67,6 @@ */ #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 ***/ diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 9afd43fec..333319b9c 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -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, -- 2.30.2