Commit 88023690 authored by Sander Temme's avatar Sander Temme
Browse files

* Move the error log slug higher in the trace function, so it gets

  executed even if the trace_add returns in the middle
* Add a direct-to-stderr path in case we don't have a server_rec to log
  for
* Remove now redundant direct-to-sterr from x_monitor callback


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@479531 13f79535-47bb-0310-9956-ffa450edef68
parent 003b8a4d
Loading
Loading
Loading
Loading
+22 −18
Changes for modules/experimental/mod_example.c: 22 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -387,6 +387,28 @@ static void trace_add(server_rec *s, request_rec *r, x_cfg *mconfig,
        x_subpool = p;
        trace_copy = trace;
    }

    /*
     * You *could* change the following if you wanted to see the calling
     * sequence reported in the server's error_log, but beware - almost all of
     * these co-routines are called for every single request, and the impact
     * on the size (and readability) of the error_log is considerable.
     */
#ifndef EXAMPLE_LOG_EACH 
#define EXAMPLE_LOG_EACH 0
#endif
    if (EXAMPLE_LOG_EACH) {
        if (s != NULL) {
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "mod_example: %s", 
                         note);
        } else {
            apr_file_t *out = NULL;
            apr_file_open_stderr(&out, p);
            apr_file_printf(out, "mod_example traced in non-loggable "
                            "context: %s\n", note);
        }
    }
    
    /*
     * 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
@@ -435,18 +457,6 @@ static void trace_add(server_rec *s, request_rec *r, x_cfg *mconfig,
    else {
        trace = trace_copy;
    }
    /*
     * You *could* change the following if you wanted to see the calling
     * sequence reported in the server's error_log, but beware - almost all of
     * these co-routines are called for every single request, and the impact
     * on the size (and readability) of the error_log is considerable.
     */
#ifndef EXAMPLE_LOG_EACH 
#define EXAMPLE_LOG_EACH 0
#endif
    if (EXAMPLE_LOG_EACH && (s != NULL)) {
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "mod_example: %s", note);
    }
}

/*--------------------------------------------------------------------------*/
@@ -1390,12 +1400,6 @@ static int x_pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type)
 */
static int x_monitor(apr_pool_t *p)
{
    apr_file_t *out = NULL;

    apr_file_open_stderr(&out, p);

    apr_file_printf(out, "Example module monitor hook handler\n");

    trace_add(NULL, NULL, NULL, "x_monitor()");
    return DECLINED;
}