trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject [trafficserver] branch master updated: Support dynamic registration to StatPages.
Date Sat, 30 Sep 2017 01:37:40 GMT
This is an automated email from the ASF dual-hosted git repository.

oknet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new f773210  Support dynamic registration to StatPages.
f773210 is described below

commit f773210e6ab9c0e920e54644b4924d5f61d62ebf
Author: Oknet Xu <xuchao@skyguard.com.cn>
AuthorDate: Thu Sep 28 17:22:14 2017 +0800

    Support dynamic registration to StatPages.
    
    The cache stat module will register to StatPages after cache system
    initialized. But there is not a mutex to protect the stat_pages[] array.
    It will leads a rare crash when proxy.config.http.wait_for_cache is
    false.
---
 proxy/StatPages.cc | 3 +++
 proxy/StatPages.h  | 1 +
 2 files changed, 4 insertions(+)

diff --git a/proxy/StatPages.cc b/proxy/StatPages.cc
index b48946f..db22090 100644
--- a/proxy/StatPages.cc
+++ b/proxy/StatPages.cc
@@ -49,17 +49,20 @@ static volatile int n_stat_pages = 0;
 void
 StatPagesManager::init()
 {
+  ink_mutex_init(&stat_pages_mutex);
   REC_EstablishStaticConfigInt32(m_enabled, "proxy.config.http_ui_enabled");
 }
 
 void
 StatPagesManager::register_http(const char *module, StatPagesFunc func)
 {
+  ink_mutex_acquire(&stat_pages_mutex);
   ink_release_assert(n_stat_pages < MAX_STAT_PAGES);
 
   stat_pages[n_stat_pages].module = (char *)ats_malloc(strlen(module) + 3);
   snprintf(stat_pages[n_stat_pages].module, strlen(module) + 3, "{%s}", module);
   stat_pages[n_stat_pages++].func = func;
+  ink_mutex_release(&stat_pages_mutex);
 }
 
 Action *
diff --git a/proxy/StatPages.h b/proxy/StatPages.h
index ba78ec7..3235b65 100644
--- a/proxy/StatPages.h
+++ b/proxy/StatPages.h
@@ -84,6 +84,7 @@ struct StatPagesManager {
   bool is_stat_page(URL *url);
   bool is_cache_inspector_page(URL *url);
   int m_enabled;
+  ink_mutex stat_pages_mutex;
 };
 
 inkcoreapi extern StatPagesManager statPagesManager;

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message