ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/fdlist.c
(Generate patch)

Comparing:
ircd-hybrid/src/fdlist.c (file contents), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid-8/src/fdlist.c (file contents), Revision 1329 by michael, Sun Apr 1 12:02:12 2012 UTC

# Line 19 | Line 19
19   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
20   *  USA
21   *
22 < *  $Id: fdlist.c,v 7.55 2005/09/26 02:21:44 adx Exp $
22 > *  $Id$
23   */
24 +
25   #include "stdinc.h"
26   #include "fdlist.h"
27   #include "client.h"  /* struct Client */
27 – #include "common.h"
28   #include "event.h"
29   #include "ircd.h"    /* GlobalSetOptions */
30   #include "irc_string.h"
31 – #include "rlimits.h"
31   #include "s_bsd.h"   /* comm_setselect */
32 < #include "s_conf.h"  /* ServerInfo */
32 > #include "conf.h"  /* ServerInfo */
33   #include "send.h"
34   #include "memory.h"
35   #include "numeric.h"
36 + #include "s_misc.h"
37 + #include "irc_res.h"
38  
39   fde_t *fd_hash[FD_HASH_SIZE];
40   fde_t *fd_next_in_loop = NULL;
# Line 74 | Line 75 | fdlist_init(void)
75   void
76   recalc_fdlimit(void *unused)
77   {
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
78    int fdmax;
79    struct rlimit limit;
80  
81 <  if (!getrlimit(RLIMIT_FD_MAX, &limit))
81 >  if (!getrlimit(RLIMIT_NOFILE, &limit))
82    {
83      limit.rlim_cur = limit.rlim_max;
84 <    setrlimit(RLIMIT_FD_MAX, &limit);
84 >    setrlimit(RLIMIT_NOFILE, &limit);
85    }
86  
87    fdmax = getdtablesize();
# Line 101 | Line 96 | recalc_fdlimit(void *unused)
96  
97    if (fdmax != hard_fdlimit)
98      execute_callback(fdlimit_cb, fdmax);
104 – #endif
99   }
100  
101   static inline unsigned int
102   hash_fd(int fd)
103   {
110 – #ifdef _WIN32
111 –  return ((((unsigned) fd) >> 2) % FD_HASH_SIZE);
112 – #else
104    return (((unsigned) fd) % FD_HASH_SIZE);
114 – #endif
105   }
106  
107   fde_t *
# Line 162 | Line 152 | fd_close(fde_t *F)
152    if (F->flags.is_socket)
153      comm_setselect(F, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
154  
155 <  if (F->dns_query != NULL)
166 <  {
167 <    delete_resolver_queries(F->dns_query);
168 <    MyFree(F->dns_query);
169 <  }
155 >  delete_resolver_queries(F);
156  
157   #ifdef HAVE_LIBCRYPTO
158    if (F->ssl)
# Line 185 | Line 171 | fd_close(fde_t *F)
171    }
172  
173    /* 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
174    close(F->fd);
195 – #endif
175    number_fd--;
176 < #ifdef INVARIANTS
177 <  memset(F, '\0', sizeof(fde_t));
199 < #endif
176 >
177 >  memset(F, 0, sizeof(fde_t));
178   }
179  
180   /*
# Line 239 | Line 217 | fd_note(fde_t *F, const char *format, ..
217   /* Make sure stdio descriptors (0-2) and profiler descriptor (3)
218   * always go somewhere harmless.  Use -foreground for profiling
219   * or executing from gdb */
242 – #ifndef _WIN32
220   void
221   close_standard_fds(void)
222   {
# Line 248 | Line 225 | close_standard_fds(void)
225    for (i = 0; i < LOWEST_SAFE_FD; i++)
226    {
227      close(i);
228 <    if (open(PATH_DEVNULL, O_RDWR) < 0)
228 >    if (open("/dev/null", O_RDWR) < 0)
229        exit(-1); /* we're hosed if we can't even open /dev/null */
230    }
231   }
255 – #endif
232  
233   void
234   close_fds(fde_t *one)
# Line 263 | Line 239 | close_fds(fde_t *one)
239    for (i = 0; i < FD_HASH_SIZE; i++)
240      for (F = fd_hash[i]; F != NULL; F = F->hnext)
241        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
242          close(F->fd);
274 – #endif  
275 –      }
243   }

Comparing:
ircd-hybrid/src/fdlist.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid-8/src/fdlist.c (property svn:keywords), Revision 1329 by michael, Sun Apr 1 12:02:12 2012 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)