From: Brian Pane Date: Sun, 6 Jan 2002 21:03:51 +0000 (+0000) Subject: Rearranged the log_request_time() code to eliminate the allocation X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ca2c82daf8421edde45f21f85076f46f13ac5ec4;p=apache Rearranged the log_request_time() code to eliminate the allocation of an 8KB buffer on the stack when not using a custom time format git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92758 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index b5b15a3718..0b86f7df74 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -446,10 +446,18 @@ static const char *log_cookie(request_rec *r, char *a) return NULL; } +static const char *log_request_time_custom(request_rec *r, char *a, + apr_exploded_time_t *xt) +{ + apr_size_t retcode; + char tstr[MAX_STRING_LEN]; + apr_strftime(tstr, &retcode, sizeof(tstr), a, xt); + return apr_pstrdup(r->pool, tstr); +} + static const char *log_request_time(request_rec *r, char *a) { apr_exploded_time_t xt; - apr_size_t retcode; /* hi. i think getting the time again at the end of the request @@ -468,9 +476,13 @@ static const char *log_request_time(request_rec *r, char *a) ap_explode_recent_localtime(&xt, r->request_time); #endif if (a && *a) { /* Custom format */ - char tstr[MAX_STRING_LEN]; - apr_strftime(tstr, &retcode, sizeof(tstr), a, &xt); - return apr_pstrdup(r->pool, tstr); + /* The custom time formatting uses a very large temp buffer + * on the stack. To avoid using so much stack space in the + * common case where we're not using a custom format, the code + * for the custom format in a separate function. (That's why + * log_request_time_custom is not inlined right here.) + */ + return log_request_time_custom(r, a, &xt); } else { /* CLF format */ char sign;