Commit 6775d0d2 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(initialize): Warn if getrlimit and sysconf don't agree on the number

of possible open files.
parent fc267c35
/*
* $Id: ramkomd.c,v 0.77 1999/04/17 12:58:03 ceder Exp $
* $Id: ramkomd.c,v 0.78 1999/04/17 15:34:07 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -44,7 +44,7 @@
#endif
static const char *
rcsid = "$Id: ramkomd.c,v 0.77 1999/04/17 12:58:03 ceder Exp $";
rcsid = "$Id: ramkomd.c,v 0.78 1999/04/17 15:34:07 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -374,13 +374,14 @@ initialize(const char *config_file)
#endif
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
{
perror("getrlimit(RLIMIT_NOFILE) failed");
exit(1);
}
if (param.no_files != -1)
{
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
{
perror("getrlimit(RLIMIT_NOFILE) failed");
exit(1);
}
if (param.no_files > rlim.rlim_max)
{
fprintf(stderr, "attempt to raise open files from %ld to %ld, "
......@@ -419,6 +420,19 @@ initialize(const char *config_file)
# endif
#endif
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
/* Check that getrlimit and sysconf/getdtablesize/the compiled default
makes sense. */
if (rlim.rlim_cur > MAX_NO_OF_CONNECTIONS + PROTECTED_FDS)
log("WARNING: getrlimit indicates that %ld files can be open, "
"but MAX_NO_OF_CONNECTIONS is only %ld\n",
(long)rlim.rlim_cur, (long)MAX_NO_OF_CONNECTIONS);
else if (rlim.rlim_cur < MAX_NO_OF_CONNECTIONS + PROTECTED_FDS)
log("warning: getrlimit indicates that only %ld files can be open, "
"but MAX_NO_OF_CONNECTIONS is %ld (this should be harmless)\n",
(long)rlim.rlim_cur, (long)MAX_NO_OF_CONNECTIONS);
#endif
go_daemon();
server_init(param.ip_client_port, param.ip_mux_port);
init_data_base();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment