stas 2003/08/20 16:10:09
Modified: src/modules/perl modperl_filter.c Log: - more tracing to help io debugging - prevent segfaults when tracing, need to check whether the filter is a mod_perl one, before trying to retrieve the perl callback function name Revision Changes Path 1.66 +29 -18 modperl-2.0/src/modules/perl/modperl_filter.c Index: modperl_filter.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- modperl_filter.c 11 Aug 2003 20:34:22 -0000 1.65 +++ modperl_filter.c 20 Aug 2003 23:10:09 -0000 1.66 @@ -5,11 +5,15 @@ #define MP_FILTER_NAME_FORMAT " %s\n\n\t" #define MP_FILTER_NAME(f) \ - ((modperl_filter_ctx_t *)f->ctx)->handler->name + (is_modperl_filter(f) \ + ? ((modperl_filter_ctx_t *)(f)->ctx)->handler->name \ + : (f)->frec->name) #define MP_FILTER_TYPE(filter) \ - ((modperl_filter_ctx_t *)filter->f->ctx)->handler->attrs & \ - MP_FILTER_CONNECTION_HANDLER ? "connection" : "request" + (is_modperl_filter(filter->f) \ + ? ((modperl_filter_ctx_t *)(filter)->f->ctx)->handler->attrs & \ + MP_FILTER_CONNECTION_HANDLER ? "connection" : "request" \ + : "unknown") #define MP_FILTER_MODE(filter) \ (filter->mode == MP_INPUT_FILTER_MODE ? "input" : "output") @@ -17,7 +21,7 @@ #define MP_FILTER_POOL(f) f->r ? f->r->pool : f->c->pool /* this function is for tracing only, it's not optimized for performance */ -static const char* next_filter_name(ap_filter_t *f) +static int is_modperl_filter(ap_filter_t *f) { const char *name = f->frec->name; @@ -26,13 +30,14 @@ !strcasecmp(name, MP_FILTER_CONNECTION_OUTPUT_NAME) || !strcasecmp(name, MP_FILTER_REQUEST_INPUT_NAME) || !strcasecmp(name, MP_FILTER_REQUEST_OUTPUT_NAME) ) { - return ((modperl_filter_ctx_t *)f->ctx)->handler->name; + return 1; } else { - return name; + return 0; } } + MP_INLINE static apr_status_t send_input_eos(modperl_filter_t *filter) { apr_bucket_alloc_t *ba = filter->f->c->bucket_alloc; @@ -110,6 +115,10 @@ work_buf = (char *)apr_pcalloc(wb->pool, sizeof(char*)*len); memcpy((void*)work_buf, buf, len); } + + MP_TRACE_f(MP_FUNC, "\n\n\tparsing headers: %d bytes [%s]\n", len, + apr_pstrmemdup(wb->pool, work_buf, len)); + status = modperl_cgi_header_parse(r, (char *)work_buf, &bodytext); wb->header_parse = 0; /* only once per-request */ @@ -147,18 +156,21 @@ MP_TRACE_f(MP_FUNC, "\n\n\twrite out: %d bytes\n" "\t\tfrom %s\n\t\tto %s filter handler\n", len, - (wb->r && wb->filters == &wb->r->output_filters) - ? "response handler" : "current filter handler", - next_filter_name(*(wb->filters))); + ((wb->r && wb->filters == &wb->r->output_filters) + ? "response handler" : "current filter handler"), + MP_FILTER_NAME(*(wb->filters))); return ap_pass_brigade(*(wb->filters), bb); } -/* if add_flush_bucket is TRUE - * and there is data to flush, - * a flush bucket is added to the tail of bb with data - * otherwise - * a flush bucket is sent in its own bb +/* flush data if any, + * if add_flush_bucket is TRUE + * if there is data to flush + * a flush bucket is added to the tail of bb with data + * else + * a flush bucket is sent in its own bb + * else + * nothing is sent */ MP_INLINE apr_status_t modperl_wbucket_flush(modperl_wbucket_t *wb, int add_flush_bucket) @@ -173,7 +185,7 @@ else if (add_flush_bucket) { rv = send_output_flush(*(wb->filters)); } - + return rv; } @@ -184,8 +196,6 @@ apr_size_t len = *wlen; *wlen = 0; - MP_TRACE_f(MP_FUNC, "\n\n\tbuffer out: %d bytes\n", len); - if ((len + wb->outcnt) > sizeof(wb->outbuf)) { apr_status_t rv; if ((rv = modperl_wbucket_flush(wb, FALSE)) != APR_SUCCESS) { @@ -239,7 +249,8 @@ MP_TRACE_f(MP_FUNC, MP_FILTER_NAME_FORMAT "new: %s %s filter (0x%lx)\n", MP_FILTER_NAME(f), - MP_FILTER_TYPE(filter), MP_FILTER_MODE(filter), + MP_FILTER_TYPE(filter), + MP_FILTER_MODE(filter), (unsigned long)filter); return filter;