httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1180671 - in /httpd/httpd/trunk: include/http_config.h modules/generators/mod_info.c modules/ssl/ssl_engine_config.c
Date Sun, 09 Oct 2011 17:55:07 GMT
Author: sf
Date: Sun Oct  9 17:55:06 2011
New Revision: 1180671

URL: http://svn.apache.org/viewvc?rev=1180671&view=rev
Log:
Consistenly use apr_file_* API instead of libc when dumping config because
mixing the two can give strange results due to buffering.

Modified:
    httpd/httpd/trunk/include/http_config.h
    httpd/httpd/trunk/modules/generators/mod_info.c
    httpd/httpd/trunk/modules/ssl/ssl_engine_config.c

Modified: httpd/httpd/trunk/include/http_config.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_config.h?rev=1180671&r1=1180670&r2=1180671&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_config.h (original)
+++ httpd/httpd/trunk/include/http_config.h Sun Oct  9 17:55:06 2011
@@ -1237,6 +1237,10 @@ AP_DECLARE_HOOK(int,check_config,(apr_po
  * only if the server was invoked to test the configuration syntax.
  * @param pconf The config pool
  * @param s The list of server_recs
+ * @note To avoid reordering problems due to different buffering, hook
+ *       functions should only apr_file_*() to print to stdout/stderr and
+ *       not simple printf()/fprintf().
+ *     
  */
 AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s))
 

Modified: httpd/httpd/trunk/modules/generators/mod_info.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_info.c?rev=1180671&r1=1180670&r2=1180671&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_info.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_info.c Sun Oct  9 17:55:06 2011
@@ -78,6 +78,8 @@ module AP_MODULE_DECLARE_DATA info_modul
 
 /* current file name when doing -DDUMP_CONFIG */
 const char *dump_config_fn_info;
+/* file handle when doing -DDUMP_CONFIG */
+apr_file_t *out = NULL;
 
 static void *create_info_config(apr_pool_t * p, server_rec * s)
 {
@@ -108,13 +110,13 @@ static void put_int_flush_right(request_
         if (r)
             ap_rputc('0' + i % 10, r);
         else
-            putchar('0' + i % 10);
+            apr_file_putc('0' + i % 10, out);
     }
     else {
         if (r)
             ap_rputs(" ", r);
         else
-            printf(" ");
+            apr_file_printf(out, " ");
     }
 }
 
@@ -149,7 +151,7 @@ static void mod_info_indent(request_rec 
                    thisfn);
         }
         else {
-            printf("# In file: %s\n", thisfn);
+            apr_file_printf(out, "# In file: %s\n", thisfn);
         }
         set_fn_info(r, thisfn);
     }
@@ -161,17 +163,17 @@ static void mod_info_indent(request_rec 
     }
     else if (linenum > 0) {
         for (i = 1; i <= nest; ++i)
-            printf("  ");
-        putchar('#');
+            apr_file_printf(out, "  ");
+        apr_file_putc('#', out);
         put_int_flush_right(r, linenum, 4);
-        printf(":\n");
+        apr_file_printf(out, ":\n");
     }
 
     for (i = 1; i <= nest; ++i) {
         if (r)
             ap_rputs("&nbsp;&nbsp;", r);
         else
-            printf("  ");
+            apr_file_printf(out, "  ");
     }
 }
 
@@ -184,7 +186,7 @@ static void mod_info_show_cmd(request_re
                    ap_escape_html(r->pool, dir->directive),
                    ap_escape_html(r->pool, dir->args));
     else
-        printf("%s %s\n", dir->directive, dir->args);
+        apr_file_printf(out, "%s %s\n", dir->directive, dir->args);
 }
 
 static void mod_info_show_open(request_rec * r, const ap_directive_t * dir,
@@ -196,7 +198,7 @@ static void mod_info_show_open(request_r
                    ap_escape_html(r->pool, dir->directive),
                    ap_escape_html(r->pool, dir->args));
     else
-        printf("%s %s\n", dir->directive, dir->args);
+        apr_file_printf(out, "%s %s\n", dir->directive, dir->args);
 }
 
 static void mod_info_show_close(request_rec * r, const ap_directive_t * dir,
@@ -209,13 +211,13 @@ static void mod_info_show_close(request_
             ap_rprintf(r, "&lt;/%s&gt;</tt></dd>",
                        ap_escape_html(r->pool, dirname + 1));
         else
-            printf("</%s>\n", dirname + 1);
+            apr_file_printf(out, "</%s>\n", dirname + 1);
     }
     else {
         if (r)
             ap_rprintf(r, "/%s</tt></dd>", ap_escape_html(r->pool, dirname));
         else
-            printf("/%s\n", dirname);
+            apr_file_printf(out, "/%s\n", dirname);
     }
 }
 
@@ -859,8 +861,10 @@ static const command_rec info_cmds[] = {
 static int check_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp,
                         server_rec *s)
 {
-    if (ap_exists_config_define("DUMP_CONFIG"))
+    if (ap_exists_config_define("DUMP_CONFIG")) {
+        apr_file_open_stdout(&out, ptemp);
         mod_info_module_cmds(NULL, NULL, ap_conftree, 0, 0);
+    }
 
     return DECLINED;
 }

Modified: httpd/httpd/trunk/modules/ssl/ssl_engine_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_engine_config.c?rev=1180671&r1=1180670&r2=1180671&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_engine_config.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_engine_config.c Sun Oct  9 17:55:06 2011
@@ -1719,9 +1719,11 @@ const char *ssl_cmd_SSLStaplingForceURL(
 
 void ssl_hook_ConfigTest(apr_pool_t *pconf, server_rec *s)
 {
+    apr_file_t *out = NULL;
     if (!ap_exists_config_define("DUMP_CERTS")) {
         return;
     }
+    apr_file_open_stdout(&out, pconf);
 
     /* Dump the filenames of all configured server certificates to
      * stdout. */
@@ -1733,7 +1735,7 @@ void ssl_hook_ConfigTest(apr_pool_t *pco
             int i;
 
             for (i = 0; (i < SSL_AIDX_MAX) && pks->cert_files[i]; i++) {
-                printf("%s\n", pks->cert_files[i]);
+                apr_file_printf(out, "%s\n", pks->cert_files[i]);
             }
         }
 



Mime
View raw message