From: Gonzalo A. <ga...@us...> - 2006-09-13 12:43:49
|
Update of /cvsroot/mod-c/mod_c/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2424/src Modified Files: mod_c.c Log Message: * Added ehtml-status handler. Index: mod_c.c =================================================================== RCS file: /cvsroot/mod-c/mod_c/src/mod_c.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** mod_c.c 8 Sep 2006 15:01:38 -0000 1.19 --- mod_c.c 13 Sep 2006 12:43:45 -0000 1.20 *************** *** 22,25 **** --- 22,26 ---- #include "lib_cache.h" #include "Session.h" + #include "Profiling.h" #include <dlfcn.h> *************** *** 33,36 **** --- 34,42 ---- static const char * ehtml_handler = "ehtml-bin"; + /** + * The name of the EHTML profile handler + */ + static const char * profile_handler = "ehtml-profile"; + mod_c_config* c_sconfig(server_rec* s) { *************** *** 50,53 **** --- 56,61 ---- } + static int EHTMLProfileHandler( request_rec *r ); + /** * Handles ehtml-bin handles. *************** *** 67,72 **** const char* msg = NULL; ! if (r->handler == NULL || ! strncmp(r->handler, ehtml_handler, sizeof(ehtml_handler)) != 0) { return DECLINED; } --- 75,86 ---- const char* msg = NULL; ! if (r->handler == NULL) ! return DECLINED; ! ! if (strncmp(r->handler, profile_handler, sizeof(profile_handler)) == 0) { ! return EHTMLProfileHandler(r); ! } ! ! if (strncmp(r->handler, ehtml_handler, sizeof(ehtml_handler)) != 0) { return DECLINED; } *************** *** 118,121 **** --- 132,174 ---- /** + * Produce EHTML profiling statistics. + * Generates a table full of profiling statistics. + * + * @param r + * The request context for this handle. + * + * @return Returns... + */ + static int EHTMLProfileHandler( request_rec *r ) + { + + void* cbdata = NULL; + struct runspec spec; + + if (r->handler == NULL || + strncmp(r->handler, profile_handler, sizeof(profile_handler)) != 0) { + return DECLINED; + } + + if (r->method_number != M_GET) + return DECLINED; + + ap_set_content_type(r, "text/plain"); + + ap_rprintf(r, "%20s %20s %11s %11s function/file:line\n", + "accum", "ncalls", "overflows", "depth"); + while (profile_tick(&cbdata, &spec), cbdata != NULL) { + ap_rprintf(r, "%llu %lld %d %d %s/%s:%d\n", + spec.accum, spec.ncalls, spec.overflows, spec.depth, + spec.name, spec.file, spec.line); + printf("%20llu %20lld %11d %11d %s/%s:%d\n", + spec.accum, spec.ncalls, spec.overflows, spec.depth, + spec.name, spec.file, spec.line); + } + + return 0; + } + + /** * Creates a 'per-dir' configuration structure and initializes it with the * default values. |