Changeset cea7bad500f166f4b98b61333b92bec7ccd29c7b

Show
Ignore:
Timestamp:
06/06/10 04:42:27 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1275799347 +0000
git-parent:

[b7db393cde5c6141c4495fdf0cd9c1e406afb918]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1275799347 +0000
Message:

fixes #291

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/eventer/eventer_impl.c

    r8135eae rcea7bad  
    3636#include "utils/noit_skiplist.h" 
    3737#include <pthread.h> 
     38#include <errno.h> 
    3839#include <assert.h> 
    3940 
    4041static struct timeval *eventer_impl_epoch = NULL; 
    4142static int EVENTER_DEBUGGING = 0; 
     43static int desired_nofiles = 1024*1024; 
    4244static pthread_mutex_t te_lock; 
    4345static noit_skiplist *timed_events = NULL; 
     
    7173 
    7274static int __default_queue_threads = 5; 
     75static int desired_limit = 1024 * 1024; 
    7376static eventer_jobq_t __global_backq, __default_jobq; 
    7477static pthread_mutex_t recurrent_lock = PTHREAD_MUTEX_INITIALIZER; 
     
    8992  } 
    9093  else if(!strcasecmp(key, "debugging")) { 
     94    desired_limit = atoi(value); 
     95    if(__default_queue_threads < 256) { 
     96      noitL(noit_error, "rlim_nofiles must be >= 256\n"); 
     97      return -1; 
     98    } 
     99    return 0; 
     100  } 
     101  else if(!strcasecmp(key, "debugging")) { 
    91102    if(strcmp(value, "0")) { 
    92103      EVENTER_DEBUGGING = 1; 
     
    114125 
    115126int eventer_impl_init() { 
    116   int i; 
     127  struct rlimit rlim; 
     128  int i, try; 
    117129  eventer_t e; 
    118130  char *evdeb; 
     
    134146  eventer_name_callback("eventer_jobq_consume_available", 
    135147                        eventer_jobq_consume_available); 
     148 
     149  getrlimit(RLIMIT_NOFILE, &rlim); 
     150  rlim.rlim_cur = rlim.rlim_max = try = desired_nofiles; 
     151  while(setrlimit(RLIMIT_NOFILE, &rlim) != 0 && errno == EPERM && try > desired_limit + 10) { 
     152    noitL(noit_debug, "setrlimit(%u) : %s\n", (u_int32_t)rlim.rlim_cur, strerror(errno)); 
     153    rlim.rlim_cur = rlim.rlim_max = --try; 
     154  } 
     155  getrlimit(RLIMIT_NOFILE, &rlim); 
     156  noitL(noit_error, "rlim { %u, % }\n", (uint32_t)rlim.rlim_cur, (uint32_t)rlim.rlim_max); 
    136157 
    137158  eventer_impl_epoch = malloc(sizeof(struct timeval));