Changeset 10

Show
Ignore:
Timestamp:
12/06/00 16:30:52 (13 years ago)
Author:
george
Message:

Replaced NR_OPEN code with calls to getrlimit/setrlimit.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config.c

    r7 r10  
    99*/ 
    1010 
    11 #include <linux/limits.h> 
    1211 
    1312#include <stdio.h> 
     
    2625extern FILE *yyin; 
    2726extern int buffsize; 
     27extern int nr_open; 
    2828 
    2929int yyparse (void); 
     
    160160  int i; 
    161161  lf->vhostdir = vhd; 
    162   lf->hash = (hash_element *) malloc (NR_OPEN * sizeof(hash_element)); 
     162  lf->hash = (hash_element *) malloc (nr_open * sizeof(hash_element)); 
    163163  fprintf( stderr, "\nZeroing vhost hash for usage!\n"); 
    164   for(i=0; i<NR_OPEN; i++) { 
     164  for(i=0; i< nr_open; i++) { 
    165165    lf->hash[i].fd = -1; 
    166166    lf->hash[i].hostheader = NULL; 
     
    274274    do { 
    275275      if(lf->vhostdir) { 
    276         for (i=0;i<NR_OPEN;i++) { 
     276        for (i=0;i< nr_open;i++) { 
    277277          if(lf->hash[i].fd>0) { 
    278278            if(!skiplocking) flock(lf->hash[i].fd, LOCK_UN); 
  • trunk/spreadlogd.c

    r9 r10  
    1414#include <unistd.h> 
    1515#include <sys/time.h> 
     16#include <sys/resource.h> 
    1617#include <sp.h> 
    1718 
     
    3132SpreadConfiguration **fds; 
    3233int fdsetsize; 
     34int nr_open; 
    3335 
    3436static char *default_configfile = "/etc/spreadlogd.conf"; 
     
    116118  if(fork()!=0) exit(0); 
    117119} 
     120int getnropen(void) { 
     121  struct rlimit rlim; 
     122  getrlimit(RLIMIT_NOFILE, &rlim); 
     123  rlim.rlim_cur = rlim.rlim_max; 
     124  setrlimit(RLIMIT_NOFILE, &rlim); 
     125  return rlim.rlim_cur; 
     126} 
    118127 
    119128int main(int argc, char **argv) { 
     
    123132  struct sigaction signalaction; 
    124133  sigset_t ourmask; 
     134        nr_open = getnropen(); 
    125135 
    126136  fdsetsize = getdtablesize();