This is an automated email from the ASF dual-hosted git repository. zwoop 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 95b70f0 Removes ref-counting from background_fetch 95b70f0 is described below commit 95b70f05decde48a7f2b8a24b1c1d8aca4ea5013 Author: Leif Hedstrom <zw...@apache.org> AuthorDate: Wed Oct 31 15:33:24 2018 -0600 Removes ref-counting from background_fetch --- plugins/background_fetch/background_fetch.cc | 11 +---------- plugins/background_fetch/configs.h | 24 ++++-------------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/plugins/background_fetch/background_fetch.cc b/plugins/background_fetch/background_fetch.cc index d253310..0dd9248 100644 --- a/plugins/background_fetch/background_fetch.cc +++ b/plugins/background_fetch/background_fetch.cc @@ -531,9 +531,6 @@ cont_handle_response(TSCont contp, TSEvent event, void *edata) } } break; - case TS_EVENT_HTTP_TXN_CLOSE: - config->release(); // Release the configuration lease when txn closes - break; default: TSError("[%s] Unknown event for this plugin", PLUGIN_NAME); TSDebug(PLUGIN_NAME, "unknown event for this plugin"); @@ -567,7 +564,6 @@ TSPluginInit(int argc, const char *argv[]) TSCont cont = TSContCreate(cont_handle_response, nullptr); gConfig = new BgFetchConfig(cont); - gConfig->acquire(); // Inc refcount, although this global config should never go out of scope while (true) { int opt = getopt_long(argc, (char *const *)argv, "lc", longopt, nullptr); @@ -624,8 +620,6 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf */, int / TSCont cont = TSContCreate(cont_handle_response, nullptr); BgFetchConfig *config = new BgFetchConfig(cont); - config->acquire(); // Inc refcount - // Parse the optional rules, wihch becomes a linked list of BgFetchRule's. if (argc > 2) { TSDebug(PLUGIN_NAME, "config file %s", argv[2]); @@ -642,7 +636,7 @@ TSRemapDeleteInstance(void *ih) { BgFetchConfig *config = static_cast<BgFetchConfig *>(ih); - config->release(); + delete config; } /////////////////////////////////////////////////////////////////////////////// @@ -664,10 +658,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo * /* rri */) if (field_loc) { BgFetchConfig *config = static_cast<BgFetchConfig *>(ih); - config->acquire(); // Inc refcount TSHttpTxnHookAdd(txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, config->getCont()); - TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, config->getCont()); - TSDebug(PLUGIN_NAME, "background fetch TSRemapDoRemap"); TSHandleMLocRelease(bufp, req_hdrs, field_loc); } diff --git a/plugins/background_fetch/configs.h b/plugins/background_fetch/configs.h index fc52dc8..f8ba7a7 100644 --- a/plugins/background_fetch/configs.h +++ b/plugins/background_fetch/configs.h @@ -39,19 +39,12 @@ class BgFetchConfig { public: BgFetchConfig(TSCont cont) : _cont(cont) { TSContDataSet(cont, static_cast<void *>(this)); } - void - acquire() - { - ++_ref_count; - } - void - release() + ~BgFetchConfig() { - TSDebug(PLUGIN_NAME, "ref_count is %d", _ref_count.load()); - if (--_ref_count == 0) { - TSDebug(PLUGIN_NAME, "configuration deleted, due to ref-counting"); - delete this; + delete _rules; + if (_cont) { + TSContDestroy(_cont); } } @@ -73,15 +66,6 @@ public: bool bgFetchAllowed(TSHttpTxn txnp) const; private: - ~BgFetchConfig() - { - delete _rules; - if (_cont) { - TSContDestroy(_cont); - } - } - TSCont _cont; BgFetchRule *_rules{nullptr}; - std::atomic<int> _ref_count{0}; };