74 |
|
void |
75 |
|
recalc_fdlimit(void *unused) |
76 |
|
{ |
77 |
– |
#ifdef _WIN32 |
78 |
– |
/* this is what WSAStartup() usually returns. Even though they say |
79 |
– |
* the value is for compatibility reasons and should be ignored, |
80 |
– |
* we actually can create even more sockets... */ |
81 |
– |
hard_fdlimit = 32767; |
82 |
– |
#else |
77 |
|
int fdmax; |
78 |
|
struct rlimit limit; |
79 |
|
|
95 |
|
|
96 |
|
if (fdmax != hard_fdlimit) |
97 |
|
execute_callback(fdlimit_cb, fdmax); |
104 |
– |
#endif |
98 |
|
} |
99 |
|
|
100 |
|
static inline unsigned int |
101 |
|
hash_fd(int fd) |
102 |
|
{ |
110 |
– |
#ifdef _WIN32 |
111 |
– |
return ((((unsigned) fd) >> 2) % FD_HASH_SIZE); |
112 |
– |
#else |
103 |
|
return (((unsigned) fd) % FD_HASH_SIZE); |
114 |
– |
#endif |
104 |
|
} |
105 |
|
|
106 |
|
fde_t * |
170 |
|
} |
171 |
|
|
172 |
|
/* Unlike squid, we're actually closing the FD here! -- adrian */ |
184 |
– |
#ifdef _WIN32 |
185 |
– |
if (F->flags.is_socket) |
186 |
– |
closesocket(F->fd); |
187 |
– |
else |
188 |
– |
CloseHandle((HANDLE)F->fd); |
189 |
– |
#else |
173 |
|
close(F->fd); |
191 |
– |
#endif |
174 |
|
number_fd--; |
175 |
|
|
176 |
|
memset(F, 0, sizeof(fde_t)); |
216 |
|
/* Make sure stdio descriptors (0-2) and profiler descriptor (3) |
217 |
|
* always go somewhere harmless. Use -foreground for profiling |
218 |
|
* or executing from gdb */ |
237 |
– |
#ifndef _WIN32 |
219 |
|
void |
220 |
|
close_standard_fds(void) |
221 |
|
{ |
228 |
|
exit(-1); /* we're hosed if we can't even open /dev/null */ |
229 |
|
} |
230 |
|
} |
250 |
– |
#endif |
231 |
|
|
232 |
|
void |
233 |
|
close_fds(fde_t *one) |
238 |
|
for (i = 0; i < FD_HASH_SIZE; i++) |
239 |
|
for (F = fd_hash[i]; F != NULL; F = F->hnext) |
240 |
|
if (F != one) |
261 |
– |
{ |
262 |
– |
#ifdef _WIN32 |
263 |
– |
if (F->flags.is_socket) |
264 |
– |
closesocket(F->fd); |
265 |
– |
else |
266 |
– |
CloseHandle((HANDLE)F->fd); |
267 |
– |
#else |
241 |
|
close(F->fd); |
269 |
– |
#endif |
270 |
– |
} |
242 |
|
} |