xD: bump the soft file descriptor limit

By default it's a mere thousand connections, which is unnecessarily
crippling our advertised ability to handle lots of them.

Thanks for the advice, Lennart.
This commit is contained in:
Přemysl Eric Janouch 2021-09-23 20:32:00 +02:00
parent cb480b4c71
commit fd9d5db1d2
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 21 additions and 1 deletions

2
NEWS
View File

@ -7,6 +7,8 @@
* xC: offer IRCnet as an IRC network to connect to, * xC: offer IRCnet as an IRC network to connect to,
rather than the lunatic new Freenode rather than the lunatic new Freenode
* xD: started bumping the soft limit on file descriptors to the hard one
1.3.0 (2021-08-07) "New World Order" 1.3.0 (2021-08-07) "New World Order"

20
xD.c
View File

@ -1,7 +1,7 @@
/* /*
* xD.c: an IRC daemon * xD.c: an IRC daemon
* *
* Copyright (c) 2014 - 2020, Přemysl Eric Janouch <p@janouch.name> * Copyright (c) 2014 - 2021, Přemysl Eric Janouch <p@janouch.name>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted. * purpose with or without fee is hereby granted.
@ -22,7 +22,9 @@
#define WANT_SYSLOG_LOGGING #define WANT_SYSLOG_LOGGING
#include "common.c" #include "common.c"
#include "xD-replies.c" #include "xD-replies.c"
#include <nl_types.h> #include <nl_types.h>
#include <sys/resource.h>
enum { PIPE_READ, PIPE_WRITE }; enum { PIPE_READ, PIPE_WRITE };
@ -3984,6 +3986,21 @@ daemonize (struct server_context *ctx)
poller_post_fork (&ctx->poller); poller_post_fork (&ctx->poller);
} }
static void
setup_limits (void)
{
struct rlimit limit;
if (getrlimit (RLIMIT_NOFILE, &limit))
{
print_warning ("%s: %s", "getrlimit", strerror (errno));
return;
}
limit.rlim_cur = limit.rlim_max;
if (setrlimit (RLIMIT_NOFILE, &limit))
print_warning ("%s: %s", "setrlimit", strerror (errno));
}
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
@ -4030,6 +4047,7 @@ main (int argc, char *argv[])
print_status (PROGRAM_NAME " " PROGRAM_VERSION " starting"); print_status (PROGRAM_NAME " " PROGRAM_VERSION " starting");
setup_signal_handlers (); setup_signal_handlers ();
setup_limits ();
init_openssl (); init_openssl ();
struct server_context ctx; struct server_context ctx;