httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject svn commit: r697920 - in /httpd/flood/trunk: CHANGES flood_config.h flood_farm.c flood_report_relative_times.c
Date Mon, 22 Sep 2008 18:13:46 GMT
Author: jerenkrantz
Date: Mon Sep 22 11:13:46 2008
New Revision: 697920

URL: http://svn.apache.org/viewvc?rev=697920&view=rev
Log:
Protect relative times report output with a mutex to avoid overlap.

* flood_config.h
  (config_t): Add thread mutex to config structure.
* flood_farm.c
  (run_farm): Create thread mutex when we create farmers structure.
* flood_report_relative_times.c
  (relative_report_t): New structure to hold pointer to a config.
  (relative_times_report_init): Create report structure and stash config.
  (relative_times_process_stats): Use thread mutex to lock printf calls.
* CHANGES: Update.

Modified:
    httpd/flood/trunk/CHANGES
    httpd/flood/trunk/flood_config.h
    httpd/flood/trunk/flood_farm.c
    httpd/flood/trunk/flood_report_relative_times.c

Modified: httpd/flood/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/flood/trunk/CHANGES?rev=697920&r1=697919&r2=697920&view=diff
==============================================================================
--- httpd/flood/trunk/CHANGES (original)
+++ httpd/flood/trunk/CHANGES Mon Sep 22 11:13:46 2008
@@ -1,5 +1,8 @@
 Changes since 1.0:
 
+* Protect relative times report output with a mutex to avoid overlap.
+  [Justin Erenkrantz]
+
 * Fix compilation error with newer gcc versions.
   [Ohad Lutzky <ohad lutzky.net>]
 

Modified: httpd/flood/trunk/flood_config.h
URL: http://svn.apache.org/viewvc/httpd/flood/trunk/flood_config.h?rev=697920&r1=697919&r2=697920&view=diff
==============================================================================
--- httpd/flood/trunk/flood_config.h (original)
+++ httpd/flood/trunk/flood_config.h Mon Sep 22 11:13:46 2008
@@ -31,6 +31,9 @@
 typedef struct {
     apr_xml_doc *doc;
     apr_pool_t *pool;
+#if APR_HAS_THREADS
+    apr_thread_mutex_t *mutex;
+#endif
 } config_t;
 
 /**

Modified: httpd/flood/trunk/flood_farm.c
URL: http://svn.apache.org/viewvc/httpd/flood/trunk/flood_farm.c?rev=697920&r1=697919&r2=697920&view=diff
==============================================================================
--- httpd/flood/trunk/flood_farm.c (original)
+++ httpd/flood/trunk/flood_farm.c Mon Sep 22 11:13:46 2008
@@ -231,6 +231,7 @@
 #if APR_HAS_THREADS
     farm->farmers = apr_pcalloc(pool, 
                                 sizeof(apr_thread_t*) * (usefarmer_count + 1));
+    apr_thread_mutex_create(&config->mutex, APR_THREAD_MUTEX_DEFAULT, pool);
 #else
     farm->farmers = apr_pcalloc(pool, 
                                 sizeof(apr_proc_t*) * (usefarmer_count + 1));

Modified: httpd/flood/trunk/flood_report_relative_times.c
URL: http://svn.apache.org/viewvc/httpd/flood/trunk/flood_report_relative_times.c?rev=697920&r1=697919&r2=697920&view=diff
==============================================================================
--- httpd/flood/trunk/flood_report_relative_times.c (original)
+++ httpd/flood/trunk/flood_report_relative_times.c Mon Sep 22 11:13:46 2008
@@ -28,9 +28,18 @@
 extern apr_file_t *local_stdout;
 extern apr_file_t *local_stderr;
 
+struct relative_report_t {
+    config_t *config;
+};
+typedef struct relative_report_t relative_report_t;
+
 apr_status_t relative_times_report_init(report_t **report, config_t *config, 
                               const char *profile_name, apr_pool_t *pool)
 {
+    relative_report_t *rr = apr_palloc(pool, sizeof(relative_report_t));
+    rr->config = config;
+
+    *report = rr;
     return APR_SUCCESS;
 }
 
@@ -39,6 +48,7 @@
 #define FLOOD_PRINT_BUF 256
     apr_size_t buflen;
     char buf[FLOOD_PRINT_BUF];
+    relative_report_t *rr = (relative_report_t*)report;
 
     buflen = apr_snprintf(buf, FLOOD_PRINT_BUF,
                           "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
@@ -61,9 +71,10 @@
         apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " %d ", verified);
     }
 
-    /* FIXME: this call may need to be in a critical section */
 #if APR_HAS_THREADS
+    apr_thread_mutex_lock(rr->config->mutex);
     apr_file_printf(local_stdout, "%s %ld %s\n", buf, apr_os_thread_current(), req->uri);
+    apr_thread_mutex_unlock(rr->config->mutex);
 #else
     apr_file_printf(local_stdout, "%s %d %s\n", buf, getpid(), req->uri);
 #endif



Mime
View raw message