/[svn]/ircd-hybrid-7.2/src/fdlist.c
ViewVC logotype

Diff of /ircd-hybrid-7.2/src/fdlist.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1000 by michael, Mon Aug 17 19:19:16 2009 UTC revision 1001 by michael, Sat Aug 29 22:44:44 2009 UTC
# Line 74  fdlist_init(void) Line 74  fdlist_init(void)
74  void  void
75  recalc_fdlimit(void *unused)  recalc_fdlimit(void *unused)
76  {  {
 #ifdef _WIN32  
   /* this is what WSAStartup() usually returns. Even though they say  
    * the value is for compatibility reasons and should be ignored,  
    * we actually can create even more sockets... */  
   hard_fdlimit = 32767;  
 #else  
77    int fdmax;    int fdmax;
78    struct rlimit limit;    struct rlimit limit;
79    
# Line 101  recalc_fdlimit(void *unused) Line 95  recalc_fdlimit(void *unused)
95    
96    if (fdmax != hard_fdlimit)    if (fdmax != hard_fdlimit)
97      execute_callback(fdlimit_cb, fdmax);      execute_callback(fdlimit_cb, fdmax);
 #endif  
98  }  }
99    
100  static inline unsigned int  static inline unsigned int
101  hash_fd(int fd)  hash_fd(int fd)
102  {  {
 #ifdef _WIN32  
   return ((((unsigned) fd) >> 2) % FD_HASH_SIZE);  
 #else  
103    return (((unsigned) fd) % FD_HASH_SIZE);    return (((unsigned) fd) % FD_HASH_SIZE);
 #endif  
104  }  }
105    
106  fde_t *  fde_t *
# Line 181  fd_close(fde_t *F) Line 170  fd_close(fde_t *F)
170    }    }
171    
172    /* Unlike squid, we're actually closing the FD here! -- adrian */    /* Unlike squid, we're actually closing the FD here! -- adrian */
 #ifdef _WIN32  
   if (F->flags.is_socket)  
     closesocket(F->fd);  
   else  
     CloseHandle((HANDLE)F->fd);  
 #else  
173    close(F->fd);    close(F->fd);
 #endif  
174    number_fd--;    number_fd--;
175    
176    memset(F, 0, sizeof(fde_t));    memset(F, 0, sizeof(fde_t));
# Line 234  fd_note(fde_t *F, const char *format, .. Line 216  fd_note(fde_t *F, const char *format, ..
216  /* Make sure stdio descriptors (0-2) and profiler descriptor (3)  /* Make sure stdio descriptors (0-2) and profiler descriptor (3)
217   * always go somewhere harmless.  Use -foreground for profiling   * always go somewhere harmless.  Use -foreground for profiling
218   * or executing from gdb */   * or executing from gdb */
 #ifndef _WIN32  
219  void  void
220  close_standard_fds(void)  close_standard_fds(void)
221  {  {
# Line 247  close_standard_fds(void) Line 228  close_standard_fds(void)
228        exit(-1); /* we're hosed if we can't even open /dev/null */        exit(-1); /* we're hosed if we can't even open /dev/null */
229    }    }
230  }  }
 #endif  
231    
232  void  void
233  close_fds(fde_t *one)  close_fds(fde_t *one)
# Line 258  close_fds(fde_t *one) Line 238  close_fds(fde_t *one)
238    for (i = 0; i < FD_HASH_SIZE; i++)    for (i = 0; i < FD_HASH_SIZE; i++)
239      for (F = fd_hash[i]; F != NULL; F = F->hnext)      for (F = fd_hash[i]; F != NULL; F = F->hnext)
240        if (F != one)        if (F != one)
       {  
 #ifdef _WIN32  
         if (F->flags.is_socket)  
           closesocket(F->fd);  
         else  
           CloseHandle((HANDLE)F->fd);  
 #else  
241          close(F->fd);          close(F->fd);
 #endif    
       }  
242  }  }

Legend:
Removed from v.1000  
changed lines
  Added in v.1001

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28