Skip to content
Snippets Groups Projects
Commit 7931172e authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Use getdtablesize to set MAX_NO_OF_CONNECTIONS if HAVE_GETDTABLESIZE

is defined in <m-config.h>.
parent 7ef675a8
Branches
Tags
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* the server, and lots of constants and configuration options. * the server, and lots of constants and configuration options.
*/ */
#include <m-config.h>
#define DEBUG /* We're still debugging and want traces. */ #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 ...@@ -109,8 +110,44 @@ extern const int MAX_CREA_MISC; /* Sum of recipients, cc_recipients, comm_to
/* /*
* Some other limits * 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 extern const int MARK_AS_READ_CHUNK; /* You can't mark more than this many
* texts as read in one call. */ * texts as read in one call. */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* It has grown! /ceder * 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> #include <m-config.h>
...@@ -220,10 +220,15 @@ main (int argc, ...@@ -220,10 +220,15 @@ main (int argc,
} }
#endif #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); s_set_storage_management(string_malloc, string_realloc, string_free);
strcpy(ip_client_port, DEFAULT_CLIENT_SERVICE); strcpy(ip_client_port, DEFAULT_CLIENT_SERVICE);
strcpy(ip_mux_port, DEFAULT_MUX_SERVICE); strcpy(ip_mux_port, DEFAULT_MUX_SERVICE);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <config.h> #include <config.h>
#include <m-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; ...@@ -105,7 +105,11 @@ const int CACHE_TEXT_STATS = 10;
* mail to kom@lysator.liu.se for more info.) * 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 const int MARK_AS_READ_CHUNK = 128; /* You can't mark more than this many
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment