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 cc728ea Minor C++ cleanup for background_fetch cc728ea is described below commit cc728ea610781eaf93e26f8c4a4005ef3d644df6 Author: Leif Hedstrom <zw...@apache.org> AuthorDate: Thu Nov 1 18:55:05 2018 -0600 Minor C++ cleanup for background_fetch --- plugins/background_fetch/background_fetch.cc | 51 +++++++++++----------------- plugins/background_fetch/configs.h | 2 +- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/plugins/background_fetch/background_fetch.cc b/plugins/background_fetch/background_fetch.cc index 0dd9248..db1c875 100644 --- a/plugins/background_fetch/background_fetch.cc +++ b/plugins/background_fetch/background_fetch.cc @@ -49,6 +49,10 @@ typedef std::unordered_map<std::string, bool> OutstandingRequests; class BgFetchState { public: + BgFetchState() = default; + BgFetchState(BgFetchState const &) = delete; + void operator=(BgFetchState const &) = delete; + static BgFetchState & getInstance() { @@ -107,13 +111,9 @@ public: } private: - BgFetchState() : _log(nullptr), _lock(TSMutexCreate()) {} - BgFetchState(BgFetchState const &); // Don't Implement - void operator=(BgFetchState const &); // Don't implement - - TSTextLogObject _log; OutstandingRequests _urls; - TSMutex _lock; + TSTextLogObject _log = nullptr; + TSMutex _lock = TSMutexCreate(); }; ////////////////////////////////////////////////////////////////////////////// @@ -121,22 +121,7 @@ private: // This is necessary, because the TXN is likely to not be available // during the time we fetch from origin. struct BgFetchData { - BgFetchData() - : hdr_loc(TS_NULL_MLOC), - url_loc(TS_NULL_MLOC), - vc(nullptr), - req_io_buf(nullptr), - resp_io_buf(nullptr), - req_io_buf_reader(nullptr), - resp_io_buf_reader(nullptr), - r_vio(nullptr), - w_vio(nullptr), - _bytes(0), - _cont(nullptr) - { - mbuf = TSMBufferCreate(); - memset(&client_ip, 0, sizeof(client_ip)); - } + BgFetchData() { memset(&client_ip, 0, sizeof(client_ip)); } ~BgFetchData() { @@ -191,21 +176,25 @@ struct BgFetchData { void schedule(); void log(TSEvent event) const; - TSMBuffer mbuf; - TSMLoc hdr_loc; - TSMLoc url_loc; + TSMBuffer mbuf = TSMBufferCreate(); + TSMLoc hdr_loc = TS_NULL_MLOC; + TSMLoc url_loc = TS_NULL_MLOC; + struct sockaddr_storage client_ip; // This is for the actual background fetch / NetVC - TSVConn vc; - TSIOBuffer req_io_buf, resp_io_buf; - TSIOBufferReader req_io_buf_reader, resp_io_buf_reader; - TSVIO r_vio, w_vio; + TSVConn vc = nullptr; + TSIOBuffer req_io_buf = nullptr; + TSIOBuffer resp_io_buf = nullptr; + TSIOBufferReader req_io_buf_reader = nullptr; + TSIOBufferReader resp_io_buf_reader = nullptr; + TSVIO r_vio = nullptr; + TSVIO w_vio = nullptr; private: std::string _url; - int64_t _bytes; - TSCont _cont; + int64_t _bytes = 0; + TSCont _cont = nullptr; }; // This sets up the data and continuation properly, this is done outside diff --git a/plugins/background_fetch/configs.h b/plugins/background_fetch/configs.h index f8ba7a7..569ebde 100644 --- a/plugins/background_fetch/configs.h +++ b/plugins/background_fetch/configs.h @@ -38,7 +38,7 @@ const char PLUGIN_NAME[] = "background_fetch"; class BgFetchConfig { public: - BgFetchConfig(TSCont cont) : _cont(cont) { TSContDataSet(cont, static_cast<void *>(this)); } + explicit BgFetchConfig(TSCont cont) : _cont(cont) { TSContDataSet(cont, static_cast<void *>(this)); } ~BgFetchConfig() {