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 * |
151 |
|
if (F->flags.is_socket) |
152 |
|
comm_setselect(F, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0); |
153 |
|
|
154 |
< |
if (F->dns_query != NULL) |
166 |
< |
{ |
167 |
< |
delete_resolver_queries(F->dns_query); |
168 |
< |
MyFree(F->dns_query); |
169 |
< |
} |
154 |
> |
delete_resolver_queries(F); |
155 |
|
|
156 |
|
#ifdef HAVE_LIBCRYPTO |
157 |
|
if (F->ssl) |
170 |
|
} |
171 |
|
|
172 |
|
/* Unlike squid, we're actually closing the FD here! -- adrian */ |
188 |
– |
#ifdef _WIN32 |
189 |
– |
if (F->flags.is_socket) |
190 |
– |
closesocket(F->fd); |
191 |
– |
else |
192 |
– |
CloseHandle((HANDLE)F->fd); |
193 |
– |
#else |
173 |
|
close(F->fd); |
195 |
– |
#endif |
174 |
|
number_fd--; |
175 |
< |
#ifdef INVARIANTS |
176 |
< |
memset(F, '\0', sizeof(fde_t)); |
199 |
< |
#endif |
175 |
> |
|
176 |
> |
memset(F, 0, sizeof(fde_t)); |
177 |
|
} |
178 |
|
|
179 |
|
/* |
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 */ |
242 |
– |
#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 |
|
} |
255 |
– |
#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) |
266 |
– |
{ |
267 |
– |
#ifdef _WIN32 |
268 |
– |
if (F->flags.is_socket) |
269 |
– |
closesocket(F->fd); |
270 |
– |
else |
271 |
– |
CloseHandle((HANDLE)F->fd); |
272 |
– |
#else |
241 |
|
close(F->fd); |
274 |
– |
#endif |
275 |
– |
} |
242 |
|
} |