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/main http_config.c http_main.c
Date Thu, 07 Oct 1999 18:13:25 GMT
bhyde       99/10/07 11:13:24

  Modified:    src/include http_config.h httpd.h
               src/main http_config.c http_main.c
  Log:
  Add process_rec to the top of {server,connection,request}_rec
  hierarchy of structs that abstract server activities.  Store some
  stuff in process_rec (finally a place to have nearly guiltless
  globals) for example the global and configuration pools.  Put some
  operations on process_rec in http_main, in particular the
  destroy_and_exit operation, and the use it to do all the exit calls.
  Change ap_read_config to operation on this "object" rather than on the
  configuration pool.  Modify server_rec to point to the process, so you
  can get at it most all the time which should finally allow most of the
  server's malloc calls to be eliminated.
  
  There are no locks in the process struct as yet, put them in as needed.
  Some of the hooks should take this rather than conf. pool.
  
  Revision  Changes    Path
  1.5       +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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- http_config.h	1999/08/31 05:32:18	1.4
  +++ http_config.h	1999/10/07 18:13:10	1.5
  @@ -326,7 +326,7 @@
   void ap_setup_prelinked_modules(void);
   void ap_show_directives(void);
   void ap_show_modules(void);
  -server_rec *ap_read_config(ap_context_t *conf_pool, ap_context_t *temp_pool, const char
*config_name);
  +server_rec *ap_read_config(process_rec *process, ap_context_t *temp_pool, const char *config_name);
   void ap_post_config_hook(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp,
server_rec *s);
   void ap_child_init_hook(ap_context_t *pchild, server_rec *s);
   
  
  
  
  1.11      +18 -2     apache-2.0/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- httpd.h	1999/10/06 21:26:51	1.10
  +++ httpd.h	1999/10/07 18:13:11	1.11
  @@ -616,12 +616,28 @@
       const struct htaccess_result *next;
   };
   
  -typedef struct conn_rec conn_rec;
  +/* The following four types define a hierarchy of activities, so that
  + * given a request_rec r you can write r->connection->server->process
  + * to get to the process_rec.  While this reduces substantially the
  + * number of arguments that various hooks require beware that in
  + * threaded versions of the server you must consider multiplexing
  + * issues.  */
  +
  +typedef struct process_rec process_rec;
   typedef struct server_rec server_rec;
  +typedef struct conn_rec conn_rec;
   typedef struct request_rec request_rec;
   
   #include "util_uri.h"
   
  +struct process_rec {
  +    ap_context_t *pool;  /* Global pool. Please try to cleared on _all_ exits */
  +    ap_context_t *pconf; /* aka configuration pool, cleared on restarts */
  +    int argc;
  +    const char **argv;
  +    const char *short_name;
  +};
  +
   struct request_rec {
   
       ap_context_t *pool;
  @@ -838,7 +854,7 @@
   };
   
   struct server_rec {
  -
  +    process_rec *process;
       server_rec *next;
   
       /* description of where the definition came from */
  
  
  
  1.12      +6 -3      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- http_config.c	1999/10/04 16:37:50	1.11
  +++ http_config.c	1999/10/07 18:13:16	1.12
  @@ -1154,6 +1154,7 @@
   #endif
   
       /* TODO: this crap belongs in http_core */
  +    s->process = main_server->process;
       s->server_admin = NULL;
       s->server_hostname = NULL;
       s->error_fname = NULL;
  @@ -1242,11 +1243,12 @@
       ap_init_vhost_config(p);
   }
   
  -static server_rec *init_server_config(ap_context_t *p)
  +static server_rec *init_server_config(process_rec *process, ap_context_t *p)
   {
       int errfile = STDERR_FILENO;
       server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec));
   
  +    s->process = process;
       s->port = 0;
       s->server_admin = DEFAULT_ADMIN;
       s->server_hostname = NULL;
  @@ -1278,9 +1280,10 @@
   }
   
   
  -server_rec *ap_read_config(ap_context_t *p, ap_context_t *ptemp, const char *confname)
  +server_rec *ap_read_config(process_rec *process, ap_context_t *ptemp, const char *confname)
   {
  -    server_rec *s = init_server_config(p);
  +    ap_context_t *p = process->pconf;
  +    server_rec *s = init_server_config(process, p);
   
       init_config_globals(p);
   
  
  
  
  1.13      +52 -28    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- http_main.c	1999/10/07 15:36:40	1.12
  +++ http_main.c	1999/10/07 18:13:17	1.13
  @@ -195,8 +195,39 @@
   #endif
   }
   
  -static void usage(char *bin)
  +static void destroy_and_exit_process(process_rec *process, int process_exit_value)
   {
  +    ap_destroy_pool(process->pool); /* and destroy all descendent pools */
  +    exit(process_exit_value);
  +}
  +
  +#define PATHSEPARATOR '/'  /* Belongs in some apr os include file */
  +
  +static process_rec *create_process(int argc, const char **argv)
  +{
  +    process_rec *process;
  +    
  +    {
  +	ap_context_t *cntx;
  +
  +	ap_create_context(&cntx, NULL);
  +	process = ap_palloc(cntx, sizeof(process_rec));
  +	process->pool = cntx;
  +    }
  +    ap_create_context(&process->pconf, process->pool);
  +    process->argc = argc;
  +    process->argv = argv;
  +    {
  +        char *s = strrchr(argv[0], PATHSEPARATOR);
  +
  +	process->short_name = s ? ++s : argv[0];
  +    }
  +    return process;
  +}
  +
  +static void usage(process_rec *process)
  +{
  +    const char *bin = process->argv[0];
       char pad[MAX_STRING_LEN];
       unsigned i;
   
  @@ -229,9 +260,13 @@
       fprintf(stderr, "  -t               : run syntax check for config files (with docroot
check)\n");
       fprintf(stderr, "  -T               : run syntax check for config files (without docroot
check)\n");
       /* TODOC: -X goes away, expect MPMs to use -D options */
  -    exit(1);
  +    destroy_and_exit_process(process, 1);
   }
   
  +
  +
  +
  +
   ap_context_t *g_pHookPool;
   
   extern char *optarg;
  @@ -244,28 +279,18 @@
   {
       int c;
       int configtestonly = 0;
  -    char *s;
       const char *confname = SERVER_CONFIG_FILE;
       const char *def_server_root = HTTPD_ROOT;
  +    process_rec *process = create_process(argc, (const char **)argv);
       server_rec *server_conf;
  -    ap_context_t *pglobal;           	/* Global pool */
  -    ap_context_t *pconf;		/* Pool for config stuff */
  +    ap_context_t *pglobal = process->pool;
  +    ap_context_t *pconf = process->pconf;
       ap_context_t *plog;			/* Pool for error-logging files */
  -    ap_context_t *ptemp;		/* Pool for temporart config stuff */
  +    ap_context_t *ptemp;		/* Pool for temporary config stuff */
       ap_context_t *pcommands;		/* Pool for -C and -c switches */
   
  -    /* TODO: PATHSEPARATOR should be one of the os defines */
  -#define PATHSEPARATOR '/'
  -    if ((s = strrchr(argv[0], PATHSEPARATOR)) != NULL) {
  -	ap_server_argv0 = ++s;
  -    }
  -    else {
  -	ap_server_argv0 = argv[0];
  -    }
  -
       ap_util_uri_init();
   
  -    ap_create_context(&pglobal, NULL);
       g_pHookPool=pglobal;
   
       ap_create_context(&pcommands, pglobal);
  @@ -295,27 +320,26 @@
   	case 'v':
   	    printf("Server version: %s\n", ap_get_server_version());
   	    printf("Server built:   %s\n", ap_get_server_built());
  -	    exit(0);
  +	    destroy_and_exit_process(process, 0);
   	case 'V':
   	    show_compile_settings();
  -	    exit(0);
  +	    destroy_and_exit_process(process, 0);
   	case 'l':
   	    ap_show_modules();
  -	    exit(0);
  +	    destroy_and_exit_process(process, 0);
   	case 'L':
   	    ap_show_directives();
  -	    exit(0);
  +	    destroy_and_exit_process(process, 0);
   	case 't':
   	    configtestonly = 1;
   	    break;
   	case 'h':
  -	    usage(argv[0]);
  +	    usage(process);
   	case '?':
  -	    usage(argv[0]);
  +	    usage(process);
   	}
       }
   
  -    ap_create_context(&pconf, pglobal);
       ap_create_context(&plog, pglobal);
       ap_create_context(&ptemp, pconf);
   
  @@ -324,11 +348,11 @@
   
       ap_server_root = def_server_root;
       ap_run_pre_config(pconf, plog, ptemp);
  -    server_conf = ap_read_config(pconf, ptemp, confname);
  +    server_conf = ap_read_config(process, ptemp, confname);
   
       if (configtestonly) {
   	fprintf(stderr, "Syntax OK\n");
  -	exit(0);
  +	destroy_and_exit_process(process, 0);
       }
   
       ap_clear_pool(plog);
  @@ -341,7 +365,7 @@
   	ap_create_context(&ptemp, pconf);
   	ap_server_root = def_server_root;
   	ap_run_pre_config(pconf, plog, ptemp);
  -	server_conf = ap_read_config(pconf, ptemp, confname);
  +	server_conf = ap_read_config(process, ptemp, confname);
   	ap_clear_pool(plog);
   	ap_run_open_logs(pconf, plog, ptemp, server_conf);
   	ap_post_config_hook(pconf, plog, ptemp, server_conf);
  @@ -349,8 +373,8 @@
   
   	if (ap_mpm_run(pconf, plog, server_conf)) break;
       }
  -    ap_destroy_pool(pglobal); /* and destroy all descendent pools */
  -    exit(0);
  +    destroy_and_exit_process(process, 0);
  +    return 0; /* Supress compiler warning. */
   }
   
   /* force Expat to be linked into the server executable */
  
  
  

Mime
View raw message