/[hydra]/hydra/src/boa.c
ViewVC logotype

Diff of /hydra/src/boa.c

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

revision 1.16 by nmav, Mon Sep 30 18:18:52 2002 UTC revision 1.17 by nmav, Wed Oct 2 19:26:15 2002 UTC
# Line 44  time_t current_time; Line 44  time_t current_time;
44  static void fixup_server_root(void);  static void fixup_server_root(void);
45  static socket_type create_server_socket(int port, int);  static socket_type create_server_socket(int port, int);
46  void hic_init(void);  void hic_init(void);
47    static void initialize_rlimits();
48  static void drop_privs(void);  static void drop_privs(void);
49  static server_params *smp_init(socket_type server_s[2]);  static server_params *smp_init(socket_type server_s[2]);
50  static void create_server_names( void);  static void create_server_names( void);
# Line 153  int main(int argc, char **argv) Line 154  int main(int argc, char **argv)
154    
155     initialize_mmap();     initialize_mmap();
156    
157     if (max_connections < 1) {     initialize_rlimits();
       struct rlimit rl;  
   
       /* has not been set explicitly */  
       c = getrlimit(RLIMIT_NOFILE, &rl);  
       if (c < 0) {  
          perror("getrlimit");  
          exit(1);  
       }  
       max_connections = rl.rlim_cur;  
    }  
158    
159     /* background ourself */     /* background ourself */
160     if (do_fork) {     if (do_fork) {
# Line 536  static void create_server_names() Line 527  static void create_server_names()
527        strcat( boa_tls_version, "\r\n");        strcat( boa_tls_version, "\r\n");
528     }     }
529  }  }
530    
531    #ifdef HAVE_GETRLIMIT
532    
533    #ifndef RLIMIT_NOFILE
534    # define RLIMIT_NOFILE RLIMIT_OFILE
535    #endif
536    
537    #ifndef LONG_MAX
538    # define LONG_MAX 2147483647L
539    #endif
540    
541    #define SET_MAX_CON( lim) \
542             if (lim == RLIM_INFINITY) { \
543                max_connections = LONG_MAX; \
544             } else { \
545                max_connections = lim; \
546             }
547    
548    static void initialize_rlimits( )
549    {
550    int c;
551    struct rlimit rl;
552    
553       if (max_connections > 0 && max_connections < 1) {
554          /* has not been set explicitly */
555          c = getrlimit(RLIMIT_NOFILE, &rl);
556          if (c < 0) {
557             perror("getrlimit");
558             exit(1);
559          }
560          SET_MAX_CON( rl.rlim_cur);
561    #ifdef HAVE_SETRLIMIT
562          if (rl.rlim_max > rl.rlim_cur) {
563             rl.rlim_cur = rl.rlim_max;
564             c = setrlimit(RLIMIT_NOFILE, &rl);
565             if (c < 0) {
566                perror("setrlimit:");
567             }
568    
569             SET_MAX_CON( rl.rlim_max);
570            
571          }
572    #endif
573       }
574    }
575    
576    #else /* rlimits are not present */
577    static void initialize_rlimits( )
578    {
579       return;
580    }
581    #endif

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26