httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bh...@hyperreal.org
Subject cvs commit: apache-2.0/src/modules/mpm/winnt winnt.c
Date Thu, 07 Oct 1999 20:48:32 GMT
bhyde       99/10/07 13:48:29

  Modified:    src/include ap_listen.h http_config.h
               src/main http_config.c http_main.c listen.c
               src/modules/mpm/dexter dexter.c
               src/modules/mpm/mpmt_pthread mpmt_pthread.c
               src/modules/mpm/prefork prefork.c
               src/modules/mpm/spmt_os2 spmt_os2.c
               src/modules/mpm/winnt winnt.c
  Log:
  Well this was thought provoking.
  
  Drive out the use of malloc in two places.
  
  In listen.c, using the global process pool instead.  That changes the
  API into listen so that a process is passed in rather than the config
  pool.  That's all was easy.
  
  The pain is propogating a change into all N of the mpm, they
  are all similar but different in their use of listen.c  There
  is a lot to dislike about similar but code scattered code.
  
  I changed the N setup_listener routines, they now take only
  the server since they can dig the config and global pool
  out of there.
  
  Free today: ap_setup_prelinked_modules now takes the process so it
  can allocate it's table in the process's pool rathern than use
  malloc.
  
  Revision  Changes    Path
  1.7       +1 -1      apache-2.0/src/include/ap_listen.h
  
  Index: ap_listen.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/ap_listen.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ap_listen.h	1999/09/24 22:01:17	1.6
  +++ ap_listen.h	1999/10/07 20:47:47	1.7
  @@ -71,7 +71,7 @@
   ap_listen_rec *ap_listeners;
   
   void ap_listen_pre_config(void);
  -int ap_listen_open(ap_context_t *pconf, unsigned port);
  +int ap_listen_open(process_rec *process, unsigned port);
   const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, char *arg);
   const char *ap_set_listener(cmd_parms *cmd, void *dummy, char *ips);
   const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, char *arg);
  
  
  
  1.6       +1 -1      apache-2.0/src/include/http_config.h
  
  Index: http_config.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/http_config.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- http_config.h	1999/10/07 18:13:10	1.5
  +++ http_config.h	1999/10/07 20:47:48	1.6
  @@ -323,7 +323,7 @@
   
   /* For http_main.c... */
   
  -void ap_setup_prelinked_modules(void);
  +void ap_setup_prelinked_modules(process_rec *process);
   void ap_show_directives(void);
   void ap_show_modules(void);
   server_rec *ap_read_config(process_rec *process, ap_context_t *temp_pool, const char *config_name);
  
  
  
  1.13      +2 -2      apache-2.0/src/main/http_config.c
  
  Index: http_config.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_config.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- http_config.c	1999/10/07 18:13:16	1.12
  +++ http_config.c	1999/10/07 20:47:52	1.13
  @@ -526,7 +526,7 @@
       *m = NULL;
   }
   
  -void ap_setup_prelinked_modules()
  +void ap_setup_prelinked_modules(process_rec *process)
   {
       module **m;
       module **m2;
  @@ -541,7 +541,7 @@
       /* 
        *  Initialise list of loaded modules
        */
  -    ap_loaded_modules = (module **)malloc(
  +    ap_loaded_modules = (module **)ap_palloc(process->pool,
           sizeof(module *)*(total_modules+DYNAMIC_MODULE_LIMIT+1));
       if (ap_loaded_modules == NULL) {
   	fprintf(stderr, "Ouch!  Out of memory in ap_setup_prelinked_modules()!\n");
  
  
  
  1.14      +2 -2      apache-2.0/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_main.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- http_main.c	1999/10/07 18:13:17	1.13
  +++ http_main.c	1999/10/07 20:47:53	1.14
  @@ -293,12 +293,12 @@
   
       g_pHookPool=pglobal;
   
  +    ap_setup_prelinked_modules(process);
  +
       ap_create_context(&pcommands, pglobal);
       ap_server_pre_read_config  = ap_make_array(pcommands, 1, sizeof(char *));
       ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
       ap_server_config_defines   = ap_make_array(pcommands, 1, sizeof(char *));
  -
  -    ap_setup_prelinked_modules();
   
       while ((c = getopt(argc, argv, "C:c:d:f:vVlLth")) != -1) {
           char **new;
  
  
  
  1.11      +7 -6      apache-2.0/src/main/listen.c
  
  Index: listen.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/listen.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- listen.c	1999/10/04 16:37:54	1.10
  +++ listen.c	1999/10/07 20:47:54	1.11
  @@ -151,7 +151,7 @@
   }
   
   
  -static void alloc_listener(char *addr, unsigned int port)
  +static void alloc_listener(process_rec *process, char *addr, unsigned int port)
   {
       ap_listen_rec **walk;
       ap_listen_rec *new;
  @@ -174,7 +174,7 @@
   
       /* this has to survive restarts */
       /* XXX - We need to deal with freeing this structure properly. */
  -    new = malloc(sizeof(ap_listen_rec));
  +    new = ap_palloc(process->pool, sizeof(ap_listen_rec));
       new->active = 0;
       if (ap_create_tcp_socket(&new->sd, NULL) != APR_SUCCESS) {
           ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
  @@ -188,15 +188,16 @@
   }
   
   
  -int ap_listen_open(ap_context_t *pconf, unsigned port)
  +int ap_listen_open(process_rec *process, unsigned port)
   {
  +    ap_context_t *pconf = process->pconf;
       ap_listen_rec *lr;
       ap_listen_rec *next;
       int num_open;
   
       /* allocate a default listener if necessary */
       if (ap_listeners == NULL) {
  -	alloc_listener(APR_ANYADDR, port ? port : DEFAULT_HTTP_PORT);
  +	alloc_listener(process, APR_ANYADDR, port ? port : DEFAULT_HTTP_PORT);
       }
   
       num_open = 0;
  @@ -265,11 +266,11 @@
       }
   
       if (ports == ips) { /* no address */
  -        alloc_listener(APR_ANYADDR, port);
  +        alloc_listener(cmd->server->process, APR_ANYADDR, port);
       }
       else {
           ips[(ports - ips) - 1] = '\0';
  -	alloc_listener(ips, port);
  +	alloc_listener(cmd->server->process, ips, port);
       }
   
       return NULL;
  
  
  
  1.40      +2 -2      apache-2.0/src/modules/mpm/dexter/dexter.c
  
  Index: dexter.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/dexter/dexter.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- dexter.c	1999/10/04 16:38:09	1.39
  +++ dexter.c	1999/10/07 20:48:09	1.40
  @@ -686,7 +686,7 @@
       ap_listen_rec *lr;
       int num_listeners = 0;
   
  -    if (ap_listen_open(p, s->port)) {
  +    if (ap_listen_open(s->process, s->port)) {
          return 0;
       }
       for (lr = ap_listeners; lr; lr = lr->next) {
  @@ -1293,7 +1293,7 @@
           exit(1);
       }
       server_conf = s;
  -    if ((num_listenfds = setup_listeners(pconf, server_conf)) < 1) {
  +    if ((num_listenfds = setup_listeners(server_conf)) < 1) {
           /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
           ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, s,
               "no listening sockets available, shutting down");
  
  
  
  1.35      +3 -3      apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c
  
  Index: mpmt_pthread.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- mpmt_pthread.c	1999/10/04 16:38:12	1.34
  +++ mpmt_pthread.c	1999/10/07 20:48:13	1.35
  @@ -674,11 +674,11 @@
       }
   }
   
  -static int setup_listeners(ap_context_t *pconf, server_rec *s)
  +static int setup_listeners(server_rec *s)
   {
       ap_listen_rec *lr;
       int num_listeners = 0;
  -    if (ap_listen_open(pconf, s->port)) {
  +    if (ap_listen_open(s->process, s->port)) {
          return 0;
       }
       for (lr = ap_listeners; lr; lr = lr->next) {
  @@ -1303,7 +1303,7 @@
           exit(1);
       }
       server_conf = s;
  -    if ((num_listenfds = setup_listeners(pconf, server_conf)) < 1) {
  +    if ((num_listenfds = setup_listeners(server_conf)) < 1) {
           /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
           ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, s,
               "no listening sockets available, shutting down");
  
  
  
  1.39      +1 -1      apache-2.0/src/modules/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/prefork/prefork.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- prefork.c	1999/10/06 23:04:14	1.38
  +++ prefork.c	1999/10/07 20:48:18	1.39
  @@ -2535,7 +2535,7 @@
       ap_listen_rec *lr;
       int sockdes;
   
  -    if (ap_listen_open(p, s->port)) {
  +    if (ap_listen_open(s->process, s->port)) {
   	ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, s,
   		    "no listening sockets available, shutting down");
   	return -1;
  
  
  
  1.12      +3 -3      apache-2.0/src/modules/mpm/spmt_os2/spmt_os2.c
  
  Index: spmt_os2.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/spmt_os2/spmt_os2.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- spmt_os2.c	1999/08/31 05:33:26	1.11
  +++ spmt_os2.c	1999/10/07 20:48:23	1.12
  @@ -1378,11 +1378,11 @@
   }
   
   
  -static int setup_listeners(ap_context_t *pconf, server_rec *s)
  +static int setup_listeners(server_rec *s)
   {
       ap_listen_rec *lr;
   
  -    if (ap_listen_open(pconf, s->port)) {
  +    if (ap_listen_open(s->process, s->port)) {
   	ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, s,
   		    "no listening sockets available, shutting down");
   	return -1;
  @@ -1413,7 +1413,7 @@
       server_conf = s;
       ap_log_pid(pconf, ap_pid_fname);
   
  -    if (setup_listeners(pconf, s)) {
  +    if (setup_listeners(s)) {
   	/* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
   	return 1;
       }
  
  
  
  1.16      +4 -4      apache-2.0/src/modules/mpm/winnt/winnt.c
  
  Index: winnt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/winnt/winnt.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- winnt.c	1999/10/05 07:01:24	1.15
  +++ winnt.c	1999/10/07 20:48:26	1.16
  @@ -363,7 +363,7 @@
       }
       return NULL;
   }
  -static int setup_listeners(ap_context_t *pconf, server_rec *s)
  +static int setup_listeners(server_rec *s)
   {
       ap_listen_rec *lr;
       int num_listeners = 0;
  @@ -372,7 +372,7 @@
       /* Setup the listeners */
       FD_ZERO(&listenfds);
   
  -    if (ap_listen_open(pconf, s->port)) {
  +    if (ap_listen_open(s->process, s->port)) {
          return 0;
       }
       for (lr = ap_listeners; lr; lr = lr->next) {
  @@ -1028,7 +1028,7 @@
   
       /* start_mutex obtained, continue into the select() loop */
       if (one_process) {
  -        setup_listeners(pconf, server_conf);
  +        setup_listeners(server_conf);
       } else {
           /* Get listeners from the parent process */
           setup_inherited_listeners(pconf, server_conf);
  @@ -1343,7 +1343,7 @@
       HANDLE process_handles[MAX_PROCESSES];
       HANDLE process_kill_events[MAX_PROCESSES];
   
  -    setup_listeners(pconf, s);
  +    setup_listeners(s);
   
       /* Create child process 
        * Should only be one in this version of Apache for WIN32 
  
  
  

Mime
View raw message