40 |
|
fde_t *fd_next_in_loop = NULL; |
41 |
|
int number_fd = LEAKED_FDS; |
42 |
|
int hard_fdlimit = 0; |
43 |
– |
struct Callback *fdlimit_cb = NULL; |
43 |
|
|
45 |
– |
static void * |
46 |
– |
changing_fdlimit(va_list args) |
47 |
– |
{ |
48 |
– |
int old_fdlimit = hard_fdlimit; |
49 |
– |
|
50 |
– |
hard_fdlimit = va_arg(args, int); |
51 |
– |
|
52 |
– |
if (ServerInfo.max_clients > MAXCLIENTS_MAX) |
53 |
– |
{ |
54 |
– |
if (old_fdlimit != 0) |
55 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
56 |
– |
"HARD_FDLIMIT changed to %d, adjusting MAXCLIENTS to %d", |
57 |
– |
hard_fdlimit, MAXCLIENTS_MAX); |
58 |
– |
|
59 |
– |
ServerInfo.max_clients = MAXCLIENTS_MAX; |
60 |
– |
} |
61 |
– |
|
62 |
– |
return NULL; |
63 |
– |
} |
64 |
– |
|
65 |
– |
void |
66 |
– |
fdlist_init(void) |
67 |
– |
{ |
68 |
– |
memset(&fd_hash, 0, sizeof(fd_hash)); |
44 |
|
|
45 |
< |
fdlimit_cb = register_callback("changing_fdlimit", changing_fdlimit); |
46 |
< |
eventAddIsh("recalc_fdlimit", recalc_fdlimit, NULL, 58); |
72 |
< |
recalc_fdlimit(NULL); |
73 |
< |
} |
74 |
< |
|
75 |
< |
void |
76 |
< |
recalc_fdlimit(void *unused) |
45 |
> |
static int |
46 |
> |
set_fdlimit(void) |
47 |
|
{ |
48 |
|
int fdmax; |
49 |
|
struct rlimit limit; |
62 |
|
|
63 |
|
/* under no condition shall this raise over 65536 |
64 |
|
* for example user ip heap is sized 2*hard_fdlimit */ |
65 |
< |
fdmax = IRCD_MIN(fdmax, 65536); |
65 |
> |
hard_fdlimit = IRCD_MIN(fdmax, 65536); |
66 |
|
|
67 |
< |
if (fdmax != hard_fdlimit) |
68 |
< |
execute_callback(fdlimit_cb, fdmax); |
67 |
> |
return -1; |
68 |
> |
} |
69 |
> |
|
70 |
> |
void |
71 |
> |
fdlist_init(void) |
72 |
> |
{ |
73 |
> |
set_fdlimit(); |
74 |
|
} |
75 |
|
|
76 |
|
static inline unsigned int |
200 |
|
for (i = 0; i < LOWEST_SAFE_FD; i++) |
201 |
|
{ |
202 |
|
close(i); |
203 |
< |
if (open(PATH_DEVNULL, O_RDWR) < 0) |
203 |
> |
if (open("/dev/null", O_RDWR) < 0) |
204 |
|
exit(-1); /* we're hosed if we can't even open /dev/null */ |
205 |
|
} |
206 |
|
} |