1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2014 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2015 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
15 |
|
* |
16 |
|
* You should have received a copy of the GNU General Public License |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
< |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
18 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
|
* USA |
20 |
|
*/ |
21 |
|
|
44 |
|
int hard_fdlimit = 0; |
45 |
|
|
46 |
|
|
47 |
< |
static int |
48 |
< |
set_fdlimit(void) |
47 |
> |
void |
48 |
> |
fdlist_init(void) |
49 |
|
{ |
50 |
|
int fdmax; |
51 |
|
struct rlimit limit; |
65 |
|
/* under no condition shall this raise over 65536 |
66 |
|
* for example user ip heap is sized 2*hard_fdlimit */ |
67 |
|
hard_fdlimit = IRCD_MIN(fdmax, 65536); |
68 |
– |
|
69 |
– |
return -1; |
70 |
– |
} |
71 |
– |
|
72 |
– |
void |
73 |
– |
fdlist_init(void) |
74 |
– |
{ |
75 |
– |
set_fdlimit(); |
68 |
|
} |
69 |
|
|
70 |
|
static inline unsigned int |
93 |
|
fd_open(fde_t *F, int fd, int is_socket, const char *desc) |
94 |
|
{ |
95 |
|
unsigned int hashv = hash_fd(fd); |
96 |
+ |
|
97 |
|
assert(fd >= 0); |
98 |
+ |
assert(!F->flags.open); |
99 |
|
|
100 |
|
F->fd = fd; |
101 |
|
F->comm_index = -1; |
119 |
|
{ |
120 |
|
unsigned int hashv = hash_fd(F->fd); |
121 |
|
|
122 |
+ |
assert(F->flags.open); |
123 |
+ |
|
124 |
|
if (F == fd_next_in_loop) |
125 |
|
fd_next_in_loop = F->hnext; |
126 |
|
|
161 |
|
{ |
162 |
|
for (unsigned int i = 0; i < FD_HASH_SIZE; ++i) |
163 |
|
for (fde_t *F = fd_hash[i]; F; F = F->hnext) |
164 |
< |
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT, |
164 |
> |
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT, |
165 |
|
"F :fd %-5d desc '%s'", F->fd, F->desc); |
166 |
|
} |
167 |
|
|
197 |
|
close(i); |
198 |
|
|
199 |
|
if (open("/dev/null", O_RDWR) < 0) |
200 |
< |
exit(-1); /* we're hosed if we can't even open /dev/null */ |
200 |
> |
exit(EXIT_FAILURE); /* we're hosed if we can't even open /dev/null */ |
201 |
|
} |
202 |
|
} |
203 |
|
|