server configuration setting. Added it to the client .AS command.
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
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;
}
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");
}
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;
}
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;
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;
}
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 {
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");
}
*/
#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 ***/
/*
* 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,