Allow fd limit change when rehashing
This commit is contained in:
parent
ef70f680c5
commit
bec08a8364
3 changed files with 32 additions and 0 deletions
|
@ -106,6 +106,7 @@ extern int ircd_ssl_ok;
|
||||||
extern int ircd_zlib_ok;
|
extern int ircd_zlib_ok;
|
||||||
extern int maxconnections;
|
extern int maxconnections;
|
||||||
|
|
||||||
|
extern void rehash_ulimit();
|
||||||
void ircd_shutdown(const char *reason) __attribute__((noreturn));
|
void ircd_shutdown(const char *reason) __attribute__((noreturn));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -354,6 +354,7 @@ do_rehash(struct Client *source_p, const char *type)
|
||||||
ilog(L_MAIN, "REHASH From %s[%s]", get_oper_name(source_p),
|
ilog(L_MAIN, "REHASH From %s[%s]", get_oper_name(source_p),
|
||||||
source_p->sockhost);
|
source_p->sockhost);
|
||||||
rehash(0);
|
rehash(0);
|
||||||
|
rehash_ulimit();
|
||||||
remote_rehash_oper_p = NULL;
|
remote_rehash_oper_p = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
30
src/ircd.c
30
src/ircd.c
|
@ -177,6 +177,35 @@ init_sys(void)
|
||||||
maxconnections = MAXCONNECTIONS;
|
maxconnections = MAXCONNECTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rehash_ulimit(void)
|
||||||
|
{
|
||||||
|
#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
|
||||||
|
struct rlimit limit;
|
||||||
|
|
||||||
|
if(!getrlimit(RLIMIT_NOFILE, &limit) && limit.rlim_cur != maxconnections)
|
||||||
|
{
|
||||||
|
if(limit.rlim_cur <= MAX_BUFFER)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: Shell FD limits are too low.\n");
|
||||||
|
fprintf(stderr, "ERROR: charybdis reserves %d FDs, shell limits must be above this\n", MAX_BUFFER);
|
||||||
|
fprintf(stderr, "ERROR: keeping old limits\n");
|
||||||
|
return;
|
||||||
|
} else if(limit.rlim_cur < maxconnections)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: ulimit decreased\n");
|
||||||
|
fprintf(stderr, "ERROR: keeping old limits\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
maxconnections = limit.rlim_cur;
|
||||||
|
|
||||||
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||||
|
"Setting maxconnections to %d", maxconnections);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif /* RLIMIT_FD_MAX */
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
make_daemon(void)
|
make_daemon(void)
|
||||||
{
|
{
|
||||||
|
@ -245,6 +274,7 @@ check_rehash(void *unused)
|
||||||
if(dorehash)
|
if(dorehash)
|
||||||
{
|
{
|
||||||
rehash(1);
|
rehash(1);
|
||||||
|
rehash_ulimit();
|
||||||
dorehash = 0;
|
dorehash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue