diff --git a/src/include/config.h b/src/include/config.h index 171752e255a067706ebf7583d8fb75dc9954713f..9e35b1639067a4dc6976c0bc8a33abd2bddccf85 100644 --- a/src/include/config.h +++ b/src/include/config.h @@ -7,6 +7,7 @@ * the server, and lots of constants and configuration options. */ +#include <m-config.h> #define DEBUG /* We're still debugging and want traces. */ @@ -109,8 +110,44 @@ extern const int MAX_CREA_MISC; /* Sum of recipients, cc_recipients, comm_to /* * Some other limits */ -extern const int MAX_NO_OF_CONNECTIONS; /* the maximum number of persons - * that can use Kom simultaneously */ + + +/* + * MAX_NO_OF_CONNECTIONS must be small enough. Each connection takes one + * file descriptor, and it is important that there are a few descriptors + * left so that it is possible to save the data base. lyskomd might crash + * if this number is too big and that many connectionattempts are made + * simultaneously. + * + * The following descriptors are open by LysKOM: + * stdin, stdout, stderr (stdin and stdout could probably be closed. + * The log() function prints to stderr.) + * TEXTFILE_NAME (always open) + * DATAFILE_NAME (often open) + * STATISTIC_NAME (open after a SIGUSR1) + * Thus, the max number of connections is the number of available file + * descriptors minus six. This has not been fully tested for a long + * while, so we subtract eight just to be on the safe side. That still + * gives 56 simultaneous users on a sun4, and that is enough for the + * time beeing. (If you need more connections you can ran a mux. Send + * mail to kom@lysator.liu.se for more info.) + */ + +#define PROTECTED_FDS 8 + +/* + * An upper limit of how many connections to LysKOM that can be opened + * simultaneously. If we HAVE_GETDTABLESIZE this is set once and for + * all at the beginning of main(). Otherwise it is determined at + * compile-time. + */ +#ifdef HAVE_GETDTABLESIZE +extern int MAX_NO_OF_CONNECTIONS; +#else +extern const int MAX_NO_OF_CONNECTIONS; +#endif + + extern const int MARK_AS_READ_CHUNK; /* You can't mark more than this many * texts as read in one call. */ diff --git a/src/server/ramkomd.c b/src/server/ramkomd.c index 07fecd51b4e2541239af48ecddb5d3112461b1a6..19695b59de0df7b451e0c6b3797703d327838f49 100644 --- a/src/server/ramkomd.c +++ b/src/server/ramkomd.c @@ -7,7 +7,7 @@ * It has grown! /ceder */ -static char *rcsid = "$Id: ramkomd.c,v 0.15 1991/08/30 01:33:51 ceder Exp $"; +static char *rcsid = "$Id: ramkomd.c,v 0.16 1991/08/30 07:07:36 ceder Exp $"; #include <m-config.h> @@ -220,10 +220,15 @@ main (int argc, } #endif +#ifdef HAVE_GETDTABLESIZE + MAX_NO_OF_CONNECTIONS = getdtablesize() - PROTECTED_FDS; +#endif + /* If we don't have getdtablesize MAX_NO_OF_CONNECTIONS is + set at compile time. */ + s_set_storage_management(string_malloc, string_realloc, string_free); - - + strcpy(ip_client_port, DEFAULT_CLIENT_SERVICE); strcpy(ip_mux_port, DEFAULT_MUX_SERVICE); diff --git a/src/server/server-config.c b/src/server/server-config.c index 01b3c5e8f69e6ee0861c4f333c45516d2a218597..2e7d94b85acd8428bc86e70cfc6e3dfeda1427ae 100644 --- a/src/server/server-config.c +++ b/src/server/server-config.c @@ -8,7 +8,7 @@ #include <config.h> #include <m-config.h> -static char *rcsid = "$Id: server-config.c,v 0.9 1991/08/30 01:32:18 ceder Exp $"; +static char *rcsid = "$Id: server-config.c,v 0.10 1991/08/30 07:07:38 ceder Exp $"; @@ -105,7 +105,11 @@ const int CACHE_TEXT_STATS = 10; * mail to kom@lysator.liu.se for more info.) */ -const int MAX_NO_OF_CONNECTIONS = (MAX_OPEN_FD - 8); +#ifdef HAVE_GETDTABLESIZE +int MAX_NO_OF_CONNECTIONS = 0; /* Initialized by main(). */ +#else +const int MAX_NO_OF_CONNECTIONS = (MAX_OPEN_FD - PROTECTED_FDS); +#endif const int MARK_AS_READ_CHUNK = 128; /* You can't mark more than this many