httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodent of Unusual Size <c...@hyperreal.com>
Subject cvs commit: apache/src/modules/example mod_example.c
Date Fri, 18 Apr 1997 18:50:51 GMT
coar        97/04/18 11:50:50

  Modified:    src/modules/example  mod_example.c
  Log:
  	Change the way in which memory for the trace information is
  	being allocated; different pools are used for different phases,
  	and data from previous phases were turning to unrecoverable
  	sludge in various pools.
  
  Reviewed by:	Ron
  
  Revision  Changes    Path
  1.7       +51 -20    apache/src/modules/example/mod_example.c
  
  Index: mod_example.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/modules/example/mod_example.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -C3 -r1.6 -r1.7
  *** mod_example.c	1997/04/16 05:47:58	1.6
  --- mod_example.c	1997/04/18 18:50:48	1.7
  ***************
  *** 104,109 ****
  --- 104,118 ----
    static char *trace = NULL;
    
    /*
  +  * To avoid leaking memory from pools other than the per-request one, we
  +  * allocate a module-private pool, and then use a sub-pool of that which gets
  +  * freed each time we modify the trace.  That way previous layers of trace
  +  * data don't get lost.
  +  */
  + static pool *example_pool = NULL;
  + static pool *example_subpool = NULL;
  + 
  + /*
     * Declare ourselves so the configuration routines can find and know us.
     * We'll fill it in at the end of the module.
     */
  ***************
  *** 260,272 ****
     * be displayed by the example_handler() routine.
     */
    static void trace_add
  ! 	(server_rec *s, pool *p, example_config *mconfig, const char *note) {
    
        char    *sofar;
        char    *addon;
        char    *where;
    
        /*
         * If we weren't passed a configuration record, we can't figure out to
         * what location this call applies.  This only happens for co-routines
         * that don't operate in a particular directory or server context.  If we
  --- 269,297 ----
     * be displayed by the example_handler() routine.
     */
    static void trace_add
  ! 	(server_rec *s, example_config *mconfig, const char *note) {
    
        char    *sofar;
        char    *addon;
        char    *where;
  +     pool    *subpool;
    
        /*
  +      * Make a new sub-pool and copy any existing trace to it.
  +      */
  +     subpool = make_sub_pool (example_pool);
  +     if (trace != NULL) {
  + 	addon = pstrcat (subpool, trace, NULL);
  +     }
  +     /*
  +      * Now, if we have a sub-pool from before, nuke it and replace with the
  +      * one we just allocated.
  +      */
  +     if (example_subpool != NULL) {
  + 	destroy_pool (example_subpool);
  +     }
  +     example_subpool = subpool;
  +     /*
         * If we weren't passed a configuration record, we can't figure out to
         * what location this call applies.  This only happens for co-routines
         * that don't operate in a particular directory or server context.  If we
  ***************
  *** 277,283 ****
        where = (where != NULL) ? where : "";
        addon = pstrcat 
    		(
  ! 		    p,
    		    "   <DT><SAMP>",
    		    note,
    		    "</SAMP>\n   </DT>\n",
  --- 302,308 ----
        where = (where != NULL) ? where : "";
        addon = pstrcat 
    		(
  ! 		    subpool,
    		    "   <DT><SAMP>",
    		    note,
    		    "</SAMP>\n   </DT>\n",
  ***************
  *** 287,300 ****
    		    NULL
    		);
        sofar = (trace == NULL) ? "" : trace;
  !     trace = pstrcat (p, sofar, addon, NULL);
        /*
         * Store a copy of the same information in the configuration record, if
         * there is one.
         */
        if (mconfig != NULL) {
    	sofar = (mconfig->trace == NULL) ? "" : mconfig->trace;
  ! 	mconfig->trace = pstrcat (p, sofar, addon, NULL);
        }
        /*
         * You *could* uncomment the following if you wanted to see the calling
  --- 312,325 ----
    		    NULL
    		);
        sofar = (trace == NULL) ? "" : trace;
  !     trace = pstrcat (subpool, sofar, addon, NULL);
        /*
         * Store a copy of the same information in the configuration record, if
         * there is one.
         */
        if (mconfig != NULL) {
    	sofar = (mconfig->trace == NULL) ? "" : mconfig->trace;
  ! 	mconfig->trace = pstrcat (subpool, sofar, addon, NULL);
        }
        /*
         * You *could* uncomment the following if you wanted to see the calling
  ***************
  *** 304,310 ****
         */
    /*
        if (s != NULL) {
  !         log_printf(s, "mod_example: %s", note);
        }
     */
    }
  --- 329,335 ----
         */
    /*
        if (s != NULL) {
  !         log_printf (s, "mod_example: %s", note);
        }
     */
    }
  ***************
  *** 336,342 ****
         * "Example Wuz Here"
         */
        cfg->local = 1;
  !     trace_add (cmd->server, cmd->pool, cfg, "cmd_example()");
        return NULL;
    }
    
  --- 361,367 ----
         * "Example Wuz Here"
         */
        cfg->local = 1;
  !     trace_add (cmd->server, cfg, "cmd_example()");
        return NULL;
    }
    
  ***************
  *** 371,377 ****
    	    *cfg;
    
        cfg = our_dconfig (r);
  !     trace_add (r->server, r->pool, cfg, "example_handler()");
        /*
         * We're about to start sending content, so we need to force the HTTP
         * headers to be sent at this point.  Otherwise, no headers will be sent
  --- 396,402 ----
    	    *cfg;
    
        cfg = our_dconfig (r);
  !     trace_add (r->server, cfg, "example_handler()");
        /*
         * We're about to start sending content, so we need to force the HTTP
         * headers to be sent at this point.  Otherwise, no headers will be sent
  ***************
  *** 510,521 ****
        char    *sname = s->server_hostname;
    
        /*
         * The arbitrary text we add to our trace entry indicates for which server
         * we're being called.
         */
        sname = (sname != NULL) ? sname : "";
        note = pstrcat (p, "example_init(", sname, ")", NULL);
  !     trace_add (s, p, NULL, note);
    }
    
    /*
  --- 535,552 ----
        char    *sname = s->server_hostname;
    
        /*
  +      * If we haven't already allocated our module-private pool, do so now.
  +      */
  +     if (example_pool == NULL) {
  + 	example_pool = make_sub_pool (NULL);
  +     };
  +     /*
         * The arbitrary text we add to our trace entry indicates for which server
         * we're being called.
         */
        sname = (sname != NULL) ? sname : "";
        note = pstrcat (p, "example_init(", sname, ")", NULL);
  !     trace_add (s, NULL, note);
    }
    
    /*
  ***************
  *** 553,559 ****
         */
        dname = (dname != NULL) ? dname : "";
        cfg->loc = pstrcat (p, "DIR(", dname, ")", NULL);
  !     trace_add (NULL, p, cfg, "example_dir_create()");
        return (void *) cfg;
    }
    
  --- 584,590 ----
         */
        dname = (dname != NULL) ? dname : "";
        cfg->loc = pstrcat (p, "DIR(", dname, ")", NULL);
  !     trace_add (NULL, cfg, "example_dir_create()");
        return (void *) cfg;
    }
    
  ***************
  *** 617,623 ****
    		"\")",
    		NULL
    	    );
  !     trace_add (NULL, p, merged_config, note);
        return (void *) merged_config;
    }
    
  --- 648,654 ----
    		"\")",
    		NULL
    	    );
  !     trace_add (NULL, merged_config, note);
        return (void *) merged_config;
    }
    
  ***************
  *** 648,654 ****
         */
        sname = (sname != NULL) ? sname : "";
        cfg->loc = pstrcat (p, "SVR(", sname, ")", NULL);
  !     trace_add (s, p, cfg, "example_server_create()");
        return (void *) cfg;
    }
    
  --- 679,685 ----
         */
        sname = (sname != NULL) ? sname : "";
        cfg->loc = pstrcat (p, "SVR(", sname, ")", NULL);
  !     trace_add (s, cfg, "example_server_create()");
        return (void *) cfg;
    }
    
  ***************
  *** 699,705 ****
    		"\")",
    		NULL
    	    );
  !     trace_add (NULL, p, merged_config, note);
        return (void *) merged_config;
    }
    
  --- 730,736 ----
    		"\")",
    		NULL
    	    );
  !     trace_add (NULL, merged_config, note);
        return (void *) merged_config;
    }
    
  ***************
  *** 722,728 ****
         * We don't actually *do* anything here, except note the fact that we were
         * called.
         */
  !     trace_add (r->server, r->pool, cfg, "example_xlate()");
        return DECLINED;
    }
    
  --- 753,759 ----
         * We don't actually *do* anything here, except note the fact that we were
         * called.
         */
  !     trace_add (r->server, cfg, "example_xlate()");
        return DECLINED;
    }
    
  ***************
  *** 745,751 ****
        /*
         * Don't do anything except log the call.
         */
  !     trace_add (r->server, r->pool, cfg, "example_ckuser()");
        return DECLINED;
    }
    
  --- 776,782 ----
        /*
         * Don't do anything except log the call.
         */
  !     trace_add (r->server, cfg, "example_ckuser()");
        return DECLINED;
    }
    
  ***************
  *** 770,776 ****
         * Log the call and return OK, or access will be denied (even though we
         * didn't actually do anything).
         */
  !     trace_add (r->server, r->pool, cfg, "example_ckauth()");
        return OK;
    }
    
  --- 801,807 ----
         * Log the call and return OK, or access will be denied (even though we
         * didn't actually do anything).
         */
  !     trace_add (r->server, cfg, "example_ckauth()");
        return OK;
    }
    
  ***************
  *** 790,796 ****
    	    *cfg;
    
        cfg = our_dconfig (r);
  !     trace_add (r->server, r->pool, cfg, "example_ckaccess()");
        return OK;
    }
    
  --- 821,827 ----
    	    *cfg;
    
        cfg = our_dconfig (r);
  !     trace_add (r->server, cfg, "example_ckaccess()");
        return OK;
    }
    
  ***************
  *** 813,819 ****
         * Log the call, but don't do anything else - and report truthfully that
         * we didn't do anything.
         */
  !     trace_add (r->server, r->pool, cfg, "example_typer()");
        return DECLINED;
    }
    
  --- 844,850 ----
         * Log the call, but don't do anything else - and report truthfully that
         * we didn't do anything.
         */
  !     trace_add (r->server, cfg, "example_typer()");
        return DECLINED;
    }
    
  ***************
  *** 835,841 ****
        /*
         * Log the call and exit.
         */
  !     trace_add (r->server, r->pool, cfg, "example_fixer()");
        return OK;
    }
    
  --- 866,872 ----
        /*
         * Log the call and exit.
         */
  !     trace_add (r->server, cfg, "example_fixer()");
        return OK;
    }
    
  ***************
  *** 853,859 ****
    	    *cfg;
    
        cfg = our_dconfig (r);
  !     trace_add (r->server, r->pool, cfg, "example_logger()");
        return DECLINED;
    }
    
  --- 884,890 ----
    	    *cfg;
    
        cfg = our_dconfig (r);
  !     trace_add (r->server, cfg, "example_logger()");
        return DECLINED;
    }
    
  ***************
  *** 872,878 ****
    	    *cfg;
    
        cfg = our_dconfig (r);
  !     trace_add (r->server, r->pool, cfg, "example_hparser()");
        return DECLINED;
    }
    
  --- 903,909 ----
    	    *cfg;
    
        cfg = our_dconfig (r);
  !     trace_add (r->server, cfg, "example_hparser()");
        return DECLINED;
    }
    
  
  
  

Mime
View raw message