You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2015/01/12 14:39:07 UTC

svn commit: r1651084 - in /httpd/httpd/branches/2.4.x: CHANGES STATUS include/ap_mmn.h include/http_log.h server/log.c

Author: jim
Date: Mon Jan 12 13:39:07 2015
New Revision: 1651084

URL: http://svn.apache.org/r1651084
Log:
Merge r1643825 from trunk:

* core: Fix -D[efined] or <Define>[d] variables lifetime accross restarts. 
        PR 57328.

Submitted-by: Armin Abfalterer <a.abfalterer gmail.com>
Reviewed/Committed-by: ylavic

Submitted by: ylavic
Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/include/ap_mmn.h
    httpd/httpd/branches/2.4.x/include/http_log.h
    httpd/httpd/branches/2.4.x/server/log.c

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1651084&r1=1651083&r2=1651084&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Mon Jan 12 13:39:07 2015
@@ -46,6 +46,9 @@ Changes with Apache 2.4.11
   *) mod_ssl: Fix recognition of OCSP stapling responses that are encoded
      improperly or too large.  [Jeff Trawick]
 
+  *) core: Add ap_log_data(), ap_log_rdata(), etc. for logging buffers.
+     [Jeff Trawick]
+
   *) mod_proxy_fcgi, mod_authnz_fcgi: stop reading the response and issue an
      error when parsing or forwarding the response fails. [Yann Ylavic]
 

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1651084&r1=1651083&r2=1651084&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Mon Jan 12 13:39:07 2015
@@ -110,16 +110,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
      2.4.x patch: trunk works
      +1 jkaluza, ylavic, covener
 
-   * core: Add ap_log_data(), ap_log_rdata(), etc. for logging buffers.
-     trunk patch: http://svn.apache.org/r1512819
-                  http://svn.apache.org/r1513461 ONLY the change to http_log.h
-                  http://svn.apache.org/r1565777
-                  http://svn.apache.org/r1643538
-     2.4.x patch: http://people.apache.org/~trawick/ap_log_data-to-2.4.x.txt
-                  (trunk works with the expected minor conflicts in CHANGES
-                  and ap_mmn.h)
-     +1: trawick, covener, rjung
-
    * mod_autoindex: Fix (add) css attribute for description column when column
                     contains no data. PR 57227. [Bruno Raoult]
      trunk patch: http://svn.apache.org/r1648201

Modified: httpd/httpd/branches/2.4.x/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_mmn.h?rev=1651084&r1=1651083&r2=1651084&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_mmn.h Mon Jan 12 13:39:07 2015
@@ -433,8 +433,9 @@
                             to util_ldap_connection_t
  * 20120211.36 (2.4.10-dev) Add ap_copy_scoreboard_worker()
  * 20120211.37 (2.4.11-dev) Add r->trailers_{in,out}
- * 20120211.38 (2.4.10-dev) Added ap_shutdown_conn().
- * 20120211.39 (2.4.10-dev) Add ap_proxy_connect_uds().
+ * 20120211.38 (2.4.11-dev) Added ap_shutdown_conn().
+ * 20120211.39 (2.4.11-dev) Add ap_proxy_connect_uds().
+ * 20120211.40 (2.4.11-dev) Add ap_log_data(), ap_log_rdata(), etc.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -442,7 +443,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20120211
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 39                   /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 40                   /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/branches/2.4.x/include/http_log.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/http_log.h?rev=1651084&r1=1651083&r2=1651084&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/http_log.h (original)
+++ httpd/httpd/branches/2.4.x/include/http_log.h Mon Jan 12 13:39:07 2015
@@ -552,6 +552,180 @@ AP_DECLARE(void) ap_log_cserror_(const c
                              __attribute__((format(printf,8,9)));
 #endif
 
+/*
+ * The buffer logging functions, ap_log_data, ap_log_rdata, ap_log_cdata,
+ * and ap_log_csdata log a buffer in printable and hex format.  The exact
+ * format is controlled by processing flags, described next.
+ */
+
+/**
+ * Processing flags for ap_log_data() et al
+ *
+ * AP_LOG_DATA_DEFAULT - default formatting, with printable chars and hex
+ * AP_LOG_DATA_SHOW_OFFSET - prefix each line with hex offset from the start
+ * of the buffer
+ */
+#define AP_LOG_DATA_DEFAULT       0
+#define AP_LOG_DATA_SHOW_OFFSET   1
+
+/**
+ * ap_log_data() - log buffers which are not related to a particular request
+ * or connection.
+ * @param file The file in which this function is called
+ * @param line The line number on which this function is called
+ * @param module_index The module_index of the module logging this buffer
+ * @param level The log level
+ * @param s The server on which we are logging
+ * @param label A label for the buffer, to be logged preceding the buffer
+ * @param data The buffer to be logged
+ * @param len The length of the buffer
+ * @param flags Special processing flags like AP_LOG_DATA_SHOW_OFFSET
+ * @note ap_log_data is implemented as a macro.
+ * @note Use APLOG_MARK to fill out file, line, and module_index
+ * @note If a request_rec is available, use that with ap_log_rdata()
+ * in preference to calling this function.  Otherwise, if a conn_rec is
+ * available, use that with ap_log_cdata() in preference to calling
+ * this function.
+ */
+#ifdef DOXYGEN
+AP_DECLARE(void) ap_log_data(const char *file, int line, int module_index,
+                             int level, const server_rec *s, const char *label,
+                             const void *data, apr_size_t len, unsigned int flags);
+#else
+#ifdef AP_HAVE_C99
+/* need additional step to expand APLOG_MARK first */
+#define ap_log_data(...) ap_log_data__(__VA_ARGS__)
+/* need server_rec *sr = ... for the case if s is verbatim NULL */
+#define ap_log_data__(file, line, mi, level, s, ...)           \
+    do { const server_rec *sr__ = s; if (APLOG_MODULE_IS_LEVEL(sr__, mi, level)) \
+             ap_log_data_(file, line, mi, level, sr__, __VA_ARGS__);    \
+    } while(0)
+#else
+#define ap_log_data ap_log_data_
+#endif
+AP_DECLARE(void) ap_log_data_(const char *file, int line, int module_index,
+                              int level, const server_rec *s, const char *label,
+                              const void *data, apr_size_t len, unsigned int flags);
+#endif
+
+/**
+ * ap_log_rdata() - log buffers which are related to a particular request.
+ * @param file The file in which this function is called
+ * @param line The line number on which this function is called
+ * @param module_index The module_index of the module logging this buffer
+ * @param level The log level
+ * @param r The request which we are logging for
+ * @param label A label for the buffer, to be logged preceding the buffer
+ * @param data The buffer to be logged
+ * @param len The length of the buffer
+ * @param flags Special processing flags like AP_LOG_DATA_SHOW_OFFSET
+ * @note ap_log_rdata is implemented as a macro.
+ * @note Use APLOG_MARK to fill out file, line, and module_index
+ * @note If a request_rec is available, use that with ap_log_rerror()
+ * in preference to calling this function.  Otherwise, if a conn_rec is
+ * available, use that with ap_log_cerror() in preference to calling
+ * this function.
+ */
+#ifdef DOXYGEN
+AP_DECLARE(void) ap_log_rdata(const char *file, int line, int module_index,
+                              int level, const request_rec *r, const char *label,
+                              const void *data, apr_size_t len, unsigned int flags);
+#else
+#ifdef AP_HAVE_C99
+/* need additional step to expand APLOG_MARK first */
+#define ap_log_rdata(...) ap_log_rdata__(__VA_ARGS__)
+#define ap_log_rdata__(file, line, mi, level, s, ...)           \
+    do { if (APLOG_R_MODULE_IS_LEVEL(r, mi, level)) \
+             ap_log_rdata_(file, line, mi, level, r, __VA_ARGS__);    \
+    } while(0)
+#else
+#define ap_log_rdata ap_log_rdata_
+#endif
+AP_DECLARE(void) ap_log_rdata_(const char *file, int line, int module_index,
+                               int level, const request_rec *r, const char *label,
+                               const void *data, apr_size_t len, unsigned int flags);
+#endif
+
+/**
+ * ap_log_cdata() - log buffers which are related to a particular connection.
+ * @param file The file in which this function is called
+ * @param line The line number on which this function is called
+ * @param module_index The module_index of the module logging this buffer
+ * @param level The log level
+ * @param c The connection which we are logging for
+ * @param label A label for the buffer, to be logged preceding the buffer
+ * @param data The buffer to be logged
+ * @param len The length of the buffer
+ * @param flags Special processing flags like AP_LOG_DATA_SHOW_OFFSET
+ * @note ap_log_cdata is implemented as a macro
+ * @note Use APLOG_MARK to fill out file, line, and module_index
+ * @note If a request_rec is available, use that with ap_log_rerror()
+ * in preference to calling this function.  Otherwise, if a conn_rec is
+ * available, use that with ap_log_cerror() in preference to calling
+ * this function.
+ */
+#ifdef DOXYGEN
+AP_DECLARE(void) ap_log_cdata(const char *file, int line, int module_index,
+                              int level, const conn_rec *c, const char *label,
+                              const void *data, apr_size_t len, unsigned int flags);
+#else
+#ifdef AP_HAVE_C99
+/* need additional step to expand APLOG_MARK first */
+#define ap_log_cdata(...) ap_log_cdata__(__VA_ARGS__)
+#define ap_log_cdata__(file, line, mi, level, c, ...)           \
+    do { if (APLOG_C_MODULE_IS_LEVEL(c, mi, level)) \
+             ap_log_cdata_(file, line, mi, level, c, __VA_ARGS__);    \
+    } while(0)
+#else
+#define ap_log_cdata ap_log_cdata_
+#endif
+AP_DECLARE(void) ap_log_cdata_(const char *file, int line, int module_index,
+                               int level, const conn_rec *c, const char *label,
+                               const void *data, apr_size_t len, unsigned int flags);
+#endif
+
+/**
+ * ap_log_csdata() - log buffers which are related to a particular connection
+ * and to a vhost other than c->base_server.
+ * @param file The file in which this function is called
+ * @param line The line number on which this function is called
+ * @param module_index The module_index of the module logging this buffer
+ * @param level The log level
+ * @param c The connection which we are logging for
+ * @param s The server which we are logging for
+ * @param label A label for the buffer, to be logged preceding the buffer
+ * @param data The buffer to be logged
+ * @param len The length of the buffer
+ * @param flags Special processing flags like AP_LOG_DATA_SHOW_OFFSET
+ * @note ap_log_csdata is implemented as a macro
+ * @note Use APLOG_MARK to fill out file, line, and module_index
+ * @note If a request_rec is available, use that with ap_log_rerror()
+ * in preference to calling this function.  Otherwise, if a conn_rec is
+ * available, use that with ap_log_cerror() in preference to calling
+ * this function.
+ */
+#ifdef DOXYGEN
+AP_DECLARE(void) ap_log_csdata(const char *file, int line, int module_index,
+                               int level, const conn_rec *c, const server_rec *s,
+                               const char *label, const void *data,
+                               apr_size_t len, unsigned int flags);
+#else
+#ifdef AP_HAVE_C99
+/* need additional step to expand APLOG_MARK first */
+#define ap_log_csdata(...) ap_log_csdata__(__VA_ARGS__)
+#define ap_log_csdata__(file, line, mi, level, c, s, ...)              \
+    do { if (APLOG_CS_MODULE_IS_LEVEL(c, s, mi, level))                \
+             ap_log_csdata_(file, line, mi, level, c, s, __VA_ARGS__); \
+    } while(0)
+#else
+#define ap_log_cdata ap_log_cdata_
+#endif
+AP_DECLARE(void) ap_log_csdata_(const char *file, int line, int module_index,
+                                int level, const conn_rec *c, const server_rec *s,
+                                const char *label, const void *data,
+                                apr_size_t len, unsigned int flags);
+#endif
+
 /**
  * Convert stderr to the error log
  * @param s The current server

Modified: httpd/httpd/branches/2.4.x/server/log.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/log.c?rev=1651084&r1=1651083&r2=1651084&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/log.c (original)
+++ httpd/httpd/branches/2.4.x/server/log.c Mon Jan 12 13:39:07 2015
@@ -1293,6 +1293,21 @@ static void log_error_core(const char *f
     }
 }
 
+/* For internal calls to log_error_core with self-composed arg lists */
+static void log_error_va_glue(const char *file, int line, int module_index,
+                              int level, apr_status_t status,
+                              const server_rec *s, const conn_rec *c,
+                              const request_rec *r, apr_pool_t *pool,
+                              const char *fmt, ...)
+{
+    va_list args;
+
+    va_start(args, fmt);
+    log_error_core(file, line, module_index, level, status, s, c, r, pool,
+                   fmt, args);
+    va_end(args);
+}
+
 AP_DECLARE(void) ap_log_error_(const char *file, int line, int module_index,
                                int level, apr_status_t status,
                                const server_rec *s, const char *fmt, ...)
@@ -1371,6 +1386,129 @@ AP_DECLARE(void) ap_log_cerror_(const ch
     va_end(args);
 }
 
+#define BYTES_LOGGED_PER_LINE 16
+#define LOG_BYTES_BUFFER_SIZE (BYTES_LOGGED_PER_LINE * 3 + 2)
+
+static void fmt_data(unsigned char *buf, const void *vdata, apr_size_t len, apr_size_t *off)
+{
+    const unsigned char *data = (const unsigned char *)vdata;
+    unsigned char *chars;
+    unsigned char *hex;
+    apr_size_t this_time = 0;
+
+    memset(buf, ' ', LOG_BYTES_BUFFER_SIZE - 1);
+    buf[LOG_BYTES_BUFFER_SIZE - 1] = '\0';
+    
+    chars = buf; /* start character dump here */
+    hex   = buf + BYTES_LOGGED_PER_LINE + 1; /* start hex dump here */
+    while (*off < len && this_time < BYTES_LOGGED_PER_LINE) {
+        unsigned char c = data[*off];
+
+        if (apr_isprint(c)
+	    && c != '\\') {  /* backslash will be escaped later, which throws
+                              * off the formatting
+                              */
+            *chars = c;
+        }
+        else {
+            *chars = '.';
+        }
+
+        if ((c >> 4) >= 10) {
+            *hex = 'a' + ((c >> 4) - 10);
+        }
+        else {
+            *hex = '0' + (c >> 4);
+        }
+
+        if ((c & 0x0F) >= 10) {
+            *(hex + 1) = 'a' + ((c & 0x0F) - 10);
+        }
+        else {
+            *(hex + 1) = '0' + (c & 0x0F);
+        }
+
+        chars += 1;
+        hex += 2;
+        *off += 1;
+        ++this_time;
+    }
+}
+
+static void log_data_core(const char *file, int line, int module_index,
+                          int level, const server_rec *s,
+                          const conn_rec *c, const request_rec *r,
+                          const char *label, const void *data, apr_size_t len,
+                          unsigned int flags)
+{
+    unsigned char buf[LOG_BYTES_BUFFER_SIZE];
+    apr_size_t off;
+    char prefix[20];
+
+    if (!(flags & AP_LOG_DATA_SHOW_OFFSET)) {
+        prefix[0] = '\0';
+    }
+
+    if (len > 0xffff) { /* bug in caller? */
+        len = 0xffff;
+    }
+
+    if (label) {
+        log_error_va_glue(file, line, module_index, level, APR_SUCCESS, s,
+                          c, r, NULL, "%s (%" APR_SIZE_T_FMT " bytes)",
+                          label, len);
+    }
+
+    off = 0;
+    while (off < len) {
+        if (flags & AP_LOG_DATA_SHOW_OFFSET) {
+            apr_snprintf(prefix, sizeof prefix, "%04x: ", (unsigned int)off);
+        }
+        fmt_data(buf, data, len, &off);
+        log_error_va_glue(file, line, module_index, level, APR_SUCCESS, s,
+                          c, r, NULL, "%s%s", prefix, buf);
+    }
+}
+
+AP_DECLARE(void) ap_log_data_(const char *file, int line, 
+                              int module_index, int level,
+                              const server_rec *s, const char *label,
+                              const void *data, apr_size_t len,
+                              unsigned int flags)
+{
+    log_data_core(file, line, module_index, level, s, NULL, NULL, label,
+                  data, len, flags);
+}
+
+AP_DECLARE(void) ap_log_rdata_(const char *file, int line,
+                               int module_index, int level,
+                               const request_rec *r, const char *label,
+                               const void *data, apr_size_t len,
+                               unsigned int flags)
+{
+    log_data_core(file, line, module_index, level, r->server, NULL, r, label,
+                  data, len, flags);
+}
+
+AP_DECLARE(void) ap_log_cdata_(const char *file, int line,
+                               int module_index, int level,
+                               const conn_rec *c, const char *label,
+                               const void *data, apr_size_t len,
+                               unsigned int flags)
+{
+    log_data_core(file, line, module_index, level, c->base_server, c, NULL,
+                  label, data, len, flags);
+}
+
+AP_DECLARE(void) ap_log_csdata_(const char *file, int line, int module_index,
+                                int level, const conn_rec *c, const server_rec *s,
+                                const char *label, const void *data,
+                                apr_size_t len, unsigned int flags)
+{
+    log_data_core(file, line, module_index, level, s, c, NULL, label, data,
+                  len, flags);
+}
+
 AP_DECLARE(void) ap_log_command_line(apr_pool_t *plog, server_rec *s)
 {
     int i;



Re: svn commit: r1651084 - in /httpd/httpd/branches/2.4.x: CHANGES STATUS include/ap_mmn.h include/http_log.h server/log.c

Posted by Marion & Christophe JAILLET <ch...@wanadoo.fr>.
Hi,

the commit message is wrong for this one. Cut'n paste error from the 
previous one.
Won't have time myself to fix it in the comming days.

Best regards
CJ



Le 12/01/2015 14:39, jim@apache.org a écrit :
> Author: jim
> Date: Mon Jan 12 13:39:07 2015
> New Revision: 1651084
>
> URL: http://svn.apache.org/r1651084
> Log:
> Merge r1643825 from trunk:
>
> * core: Fix -D[efined] or <Define>[d] variables lifetime accross restarts.
>          PR 57328.
>
> Submitted-by: Armin Abfalterer <a.abfalterer gmail.com>
> Reviewed/Committed-by: ylavic
>
> Submitted by: ylavic
> Reviewed/backported by: jim
>
> Modified:
>      httpd/httpd/branches/2.4.x/CHANGES
>      httpd/httpd/branches/2.4.x/STATUS
>      httpd/httpd/branches/2.4.x/include/ap_mmn.h
>      httpd/httpd/branches/2.4.x/include/http_log.h
>      httpd/httpd/branches/2.4.x/server/log.c
>
> Modified: httpd/httpd/branches/2.4.x/CHANGES
> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1651084&r1=1651083&r2=1651084&view=diff
> ==============================================================================
> --- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
> +++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Mon Jan 12 13:39:07 2015
> @@ -46,6 +46,9 @@ Changes with Apache 2.4.11
>     *) mod_ssl: Fix recognition of OCSP stapling responses that are encoded
>        improperly or too large.  [Jeff Trawick]
>   
> +  *) core: Add ap_log_data(), ap_log_rdata(), etc. for logging buffers.
> +     [Jeff Trawick]
> +
>     *) mod_proxy_fcgi, mod_authnz_fcgi: stop reading the response and issue an
>        error when parsing or forwarding the response fails. [Yann Ylavic]
>