From dd3c789916e8a0083f718896fef149e91a658293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Sat, 7 Dec 2019 14:45:26 -0500 Subject: [PATCH] proxy server: 0-initialize fields --- include/opendht/callbacks.h | 6 +++--- include/opendht/dht_proxy_server.h | 12 +++++------- src/dht_proxy_server.cpp | 6 ++++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/opendht/callbacks.h b/include/opendht/callbacks.h index 5619b927..07b90bb4 100644 --- a/include/opendht/callbacks.h +++ b/include/opendht/callbacks.h @@ -76,9 +76,9 @@ struct OPENDHT_PUBLIC NodeStats { struct OPENDHT_PUBLIC NodeInfo { InfoHash id; InfoHash node_id; - NodeStats ipv4; - NodeStats ipv6; - size_t ongoing_ops; + NodeStats ipv4 {}; + NodeStats ipv6 {}; + size_t ongoing_ops {0}; #ifdef OPENDHT_JSONCPP /** diff --git a/include/opendht/dht_proxy_server.h b/include/opendht/dht_proxy_server.h index cd094da1..3d4e7821 100644 --- a/include/opendht/dht_proxy_server.h +++ b/include/opendht/dht_proxy_server.h @@ -54,8 +54,6 @@ class DhtRunner; using RestRouter = restinio::router::express_router_t<>; using RequestStatus = restinio::request_handling_status_t; -using ResponseByParts = restinio::chunked_output_t; -using ResponseByPartsBuilder = restinio::response_builder_t<ResponseByParts>; /** * Describes the REST API @@ -87,15 +85,15 @@ public: struct ServerStats { /** Current number of listen operations */ - size_t listenCount; + size_t listenCount {0}; /** Current number of permanent put operations */ - size_t putCount; + size_t putCount {0}; /** Current number of push tokens with at least one listen operation */ - size_t pushListenersCount; + size_t pushListenersCount {0}; /** Average requests per second */ - double requestRate; + double requestRate {0}; /** Node Info **/ - NodeInfo nodeInfo; + NodeInfo nodeInfo {}; std::string toString() const { std::ostringstream ss; diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp index 018db9e8..3d5966a7 100644 --- a/src/dht_proxy_server.cpp +++ b/src/dht_proxy_server.cpp @@ -68,6 +68,9 @@ constexpr char RESP_MSG_NO_TOKEN[] = "{\"err\":\"No token\"}"; constexpr const std::chrono::minutes PRINT_STATS_PERIOD {2}; +using ResponseByParts = restinio::chunked_output_t; +using ResponseByPartsBuilder = restinio::response_builder_t<ResponseByParts>; + class opendht_logger_t { public: @@ -957,7 +960,7 @@ DhtProxyServer::put(restinio::request_handle_t request, if (logger_) logger_->d("[proxy:server] [put %s] %s %s", infoHash.toString().c_str(), value->toString().c_str(), (permanent ? "permanent" : "")); - if (permanent){ + if (permanent) { std::string pushToken, clientId, platform; auto& pVal = root["permanent"]; if (pVal.isObject()){ @@ -1003,7 +1006,6 @@ DhtProxyServer::put(restinio::request_handle_t request, if (pput.expireNotifyTimer) pput.expireNotifyTimer->expires_at(timeout - proxy::OP_MARGIN); } - lock.unlock(); } dht_->put(infoHash, value, [this, request, value](bool ok){ if (ok){ -- GitLab