From 3a3f65daa6641e1a303dc7c88abaf50b6b5e5e8c Mon Sep 17 00:00:00 2001 From: Carsten Patzke <carsten.patzke@desy.de> Date: Wed, 8 Apr 2020 17:48:27 +0200 Subject: [PATCH] [fabric::rds] Removed wrong const. WTF there was even mutable in the code. --- .../src/receiver_data_server/rds_net_server.h | 8 +++--- .../receiver_data_server_request_handler.cpp | 2 +- .../receiver_data_server_request_handler.h | 4 +-- ...er_data_server_request_handler_factory.cpp | 2 +- ...iver_data_server_request_handler_factory.h | 4 +-- .../src/receiver_data_server/tcp_server.cpp | 17 ++++++------ .../src/receiver_data_server/tcp_server.h | 20 +++++++------- .../receiver_dataserver_mocking.h | 26 +++++++++---------- 8 files changed, 41 insertions(+), 42 deletions(-) diff --git a/receiver/src/receiver_data_server/rds_net_server.h b/receiver/src/receiver_data_server/rds_net_server.h index 933a66123..ee49cc4af 100644 --- a/receiver/src/receiver_data_server/rds_net_server.h +++ b/receiver/src/receiver_data_server/rds_net_server.h @@ -13,13 +13,13 @@ class RdsNetServer { * It is very important that this function is successfully called, before any other call is is made! */ virtual Error Initialize() = 0; - virtual GenericRequests GetNewRequests(Error* err) const noexcept = 0; + virtual GenericRequests GetNewRequests(Error* err) = 0; virtual Error SendResponse(const ReceiverDataServerRequest* request, - const GenericNetworkResponse* response) const noexcept = 0; + const GenericNetworkResponse* response) = 0; virtual Error SendResponseAndSlotData(const ReceiverDataServerRequest* request, const GenericNetworkResponse* response, - const CacheMeta* cache_slot) const noexcept = 0; - virtual void HandleAfterError(uint64_t source_id) const noexcept = 0; + const CacheMeta* cache_slot) = 0; + virtual void HandleAfterError(uint64_t source_id) = 0; virtual ~RdsNetServer() = default; }; diff --git a/receiver/src/receiver_data_server/receiver_data_server_request_handler.cpp b/receiver/src/receiver_data_server/receiver_data_server_request_handler.cpp index af648156d..bc45e229e 100644 --- a/receiver/src/receiver_data_server/receiver_data_server_request_handler.cpp +++ b/receiver/src/receiver_data_server/receiver_data_server_request_handler.cpp @@ -4,7 +4,7 @@ namespace asapo { -ReceiverDataServerRequestHandler::ReceiverDataServerRequestHandler(const RdsNetServer* server, +ReceiverDataServerRequestHandler::ReceiverDataServerRequestHandler(RdsNetServer* server, DataCache* data_cache, Statistics* statistics): log__{GetDefaultReceiverDataServerLogger()}, statistics__{statistics}, server_{server}, data_cache_{data_cache} { diff --git a/receiver/src/receiver_data_server/receiver_data_server_request_handler.h b/receiver/src/receiver_data_server/receiver_data_server_request_handler.h index 2fdc005d7..44abf4ea5 100644 --- a/receiver/src/receiver_data_server/receiver_data_server_request_handler.h +++ b/receiver/src/receiver_data_server/receiver_data_server_request_handler.h @@ -12,7 +12,7 @@ namespace asapo { class ReceiverDataServerRequestHandler: public RequestHandler { public: - explicit ReceiverDataServerRequestHandler(const RdsNetServer* server, DataCache* data_cache, Statistics* statistics); + explicit ReceiverDataServerRequestHandler(RdsNetServer* server, DataCache* data_cache, Statistics* statistics); bool ProcessRequestUnlocked(GenericRequest* request, bool* retry) override; bool ReadyProcessRequest() override; void PrepareProcessingRequestLocked() override; @@ -22,7 +22,7 @@ class ReceiverDataServerRequestHandler: public RequestHandler { const AbstractLogger* log__; Statistics* statistics__; private: - const RdsNetServer* server_; + RdsNetServer* server_; DataCache* data_cache_; bool CheckRequest(const ReceiverDataServerRequest* request); Error SendResponse(const ReceiverDataServerRequest* request, NetworkErrorCode code); diff --git a/receiver/src/receiver_data_server/receiver_data_server_request_handler_factory.cpp b/receiver/src/receiver_data_server/receiver_data_server_request_handler_factory.cpp index 6bb83b77c..d08f13a8c 100644 --- a/receiver/src/receiver_data_server/receiver_data_server_request_handler_factory.cpp +++ b/receiver/src/receiver_data_server/receiver_data_server_request_handler_factory.cpp @@ -8,7 +8,7 @@ std::unique_ptr<RequestHandler> ReceiverDataServerRequestHandlerFactory::NewRequ uint64_t* shared_counter) { return std::unique_ptr<RequestHandler> {new ReceiverDataServerRequestHandler(server_, data_cache_, statistics_)}; } -ReceiverDataServerRequestHandlerFactory::ReceiverDataServerRequestHandlerFactory(const RdsNetServer* server, +ReceiverDataServerRequestHandlerFactory::ReceiverDataServerRequestHandlerFactory(RdsNetServer* server, DataCache* data_cache, Statistics* statistics) : server_{server}, data_cache_{data_cache}, statistics_{statistics} { diff --git a/receiver/src/receiver_data_server/receiver_data_server_request_handler_factory.h b/receiver/src/receiver_data_server/receiver_data_server_request_handler_factory.h index 29e23e166..29b26dbce 100644 --- a/receiver/src/receiver_data_server/receiver_data_server_request_handler_factory.h +++ b/receiver/src/receiver_data_server/receiver_data_server_request_handler_factory.h @@ -13,10 +13,10 @@ namespace asapo { class ReceiverDataServerRequestHandlerFactory : public RequestHandlerFactory { public: - ReceiverDataServerRequestHandlerFactory (const RdsNetServer* server, DataCache* data_cache, Statistics* statistics); + ReceiverDataServerRequestHandlerFactory(RdsNetServer* server, DataCache* data_cache, Statistics* statistics); VIRTUAL std::unique_ptr<RequestHandler> NewRequestHandler(uint64_t thread_id, uint64_t* shared_counter) override; private: - const RdsNetServer* server_; + RdsNetServer* server_; DataCache* data_cache_; Statistics* statistics_; }; diff --git a/receiver/src/receiver_data_server/tcp_server.cpp b/receiver/src/receiver_data_server/tcp_server.cpp index 589ecdd27..bd8bb807c 100644 --- a/receiver/src/receiver_data_server/tcp_server.cpp +++ b/receiver/src/receiver_data_server/tcp_server.cpp @@ -24,7 +24,7 @@ Error TcpServer::Initialize() { return err; } -ListSocketDescriptors TcpServer::GetActiveSockets(Error* err) const noexcept { +ListSocketDescriptors TcpServer::GetActiveSockets(Error* err) { std::vector<std::string> new_connections; auto sockets = io__->WaitSocketsActivity(master_socket_, &sockets_to_listen_, &new_connections, err); for (auto& connection : new_connections) { @@ -33,14 +33,14 @@ ListSocketDescriptors TcpServer::GetActiveSockets(Error* err) const noexcept { return sockets; } -void TcpServer::CloseSocket(SocketDescriptor socket) const noexcept { +void TcpServer::CloseSocket(SocketDescriptor socket) { sockets_to_listen_.erase(std::remove(sockets_to_listen_.begin(), sockets_to_listen_.end(), socket), sockets_to_listen_.end()); log__->Debug("connection " + io__->AddressFromSocket(socket) + " closed"); io__->CloseSocket(socket, nullptr); } -ReceiverDataServerRequestPtr TcpServer::ReadRequest(SocketDescriptor socket, Error* err) const noexcept { +ReceiverDataServerRequestPtr TcpServer::ReadRequest(SocketDescriptor socket, Error* err) { GenericRequestHeader header; io__->Receive(socket, &header, sizeof(GenericRequestHeader), err); @@ -56,7 +56,7 @@ ReceiverDataServerRequestPtr TcpServer::ReadRequest(SocketDescriptor socket, Err return ReceiverDataServerRequestPtr{new ReceiverDataServerRequest{header, (uint64_t) socket}}; } -GenericRequests TcpServer::ReadRequests(const ListSocketDescriptors& sockets) const noexcept { +GenericRequests TcpServer::ReadRequests(const ListSocketDescriptors& sockets) { GenericRequests requests; for (auto client : sockets) { Error err; @@ -71,7 +71,7 @@ GenericRequests TcpServer::ReadRequests(const ListSocketDescriptors& sockets) co return requests; } -GenericRequests TcpServer::GetNewRequests(Error* err) const noexcept { +GenericRequests TcpServer::GetNewRequests(Error* err) { auto sockets = GetActiveSockets(err); if (*err) { return {}; @@ -88,12 +88,11 @@ TcpServer::~TcpServer() { io__->CloseSocket(master_socket_, nullptr); } -void TcpServer::HandleAfterError(uint64_t source_id) const noexcept { +void TcpServer::HandleAfterError(uint64_t source_id) { CloseSocket(source_id); } -Error TcpServer::SendResponse(const ReceiverDataServerRequest* request, - const GenericNetworkResponse* response) const noexcept { +Error TcpServer::SendResponse(const ReceiverDataServerRequest* request, const GenericNetworkResponse* response) { Error err; io__->Send(request->source_id, response, sizeof(*response), &err); if (err) { @@ -104,7 +103,7 @@ Error TcpServer::SendResponse(const ReceiverDataServerRequest* request, Error TcpServer::SendResponseAndSlotData(const ReceiverDataServerRequest* request, const GenericNetworkResponse* response, - const CacheMeta* cache_slot) const noexcept { + const CacheMeta* cache_slot) { Error err; err = SendResponse(request, response); diff --git a/receiver/src/receiver_data_server/tcp_server.h b/receiver/src/receiver_data_server/tcp_server.h index 070de6516..bf27acafc 100644 --- a/receiver/src/receiver_data_server/tcp_server.h +++ b/receiver/src/receiver_data_server/tcp_server.h @@ -16,21 +16,21 @@ class TcpServer : public RdsNetServer { Error Initialize() override; - GenericRequests GetNewRequests(Error* err) const noexcept override; + GenericRequests GetNewRequests(Error* err) override; Error SendResponse(const ReceiverDataServerRequest* request, - const GenericNetworkResponse* response) const noexcept override; + const GenericNetworkResponse* response) override; Error SendResponseAndSlotData(const ReceiverDataServerRequest* request, const GenericNetworkResponse* response, - const CacheMeta* cache_slot) const noexcept override; - void HandleAfterError(uint64_t source_id) const noexcept override; + const CacheMeta* cache_slot) override; + void HandleAfterError(uint64_t source_id) override; std::unique_ptr<IO> io__; const AbstractLogger* log__; private: - void CloseSocket(SocketDescriptor socket) const noexcept; - ListSocketDescriptors GetActiveSockets(Error* err) const noexcept; - ReceiverDataServerRequestPtr ReadRequest(SocketDescriptor socket, Error* err) const noexcept; - GenericRequests ReadRequests(const ListSocketDescriptors& sockets) const noexcept; - mutable SocketDescriptor master_socket_{kDisconnectedSocketDescriptor}; - mutable ListSocketDescriptors sockets_to_listen_; + void CloseSocket(SocketDescriptor socket); + ListSocketDescriptors GetActiveSockets(Error* err); + ReceiverDataServerRequestPtr ReadRequest(SocketDescriptor socket, Error* err) ; + GenericRequests ReadRequests(const ListSocketDescriptors& sockets); + SocketDescriptor master_socket_{kDisconnectedSocketDescriptor}; + ListSocketDescriptors sockets_to_listen_; std::string address_; }; diff --git a/receiver/unittests/receiver_data_server/receiver_dataserver_mocking.h b/receiver/unittests/receiver_data_server/receiver_dataserver_mocking.h index f0ba5fa8b..5db8ab205 100644 --- a/receiver/unittests/receiver_data_server/receiver_dataserver_mocking.h +++ b/receiver/unittests/receiver_data_server/receiver_dataserver_mocking.h @@ -15,9 +15,9 @@ class MockNetServer : public RdsNetServer { Error Initialize() override { return Error{Initialize_t()}; }; - MOCK_CONST_METHOD0(Initialize_t, ErrorInterface * ()); + MOCK_METHOD0(Initialize_t, ErrorInterface * ()); - GenericRequests GetNewRequests(Error* err) const noexcept override { + GenericRequests GetNewRequests(Error* err) override { ErrorInterface* error = nullptr; auto reqs = GetNewRequests_t(&error); err->reset(error); @@ -29,29 +29,29 @@ class MockNetServer : public RdsNetServer { return res; } - MOCK_CONST_METHOD1(GetNewRequests_t, std::vector<ReceiverDataServerRequest> (ErrorInterface** - error)); + MOCK_METHOD1(GetNewRequests_t, std::vector<ReceiverDataServerRequest> (ErrorInterface** + error)); Error SendResponse(const ReceiverDataServerRequest* request, - const GenericNetworkResponse* response) const noexcept override { + const GenericNetworkResponse* response) override { return Error{SendResponse_t(request, response)}; }; - MOCK_CONST_METHOD2(SendResponse_t, ErrorInterface * (const ReceiverDataServerRequest* request, - const GenericNetworkResponse* response)); + MOCK_METHOD2(SendResponse_t, ErrorInterface * (const ReceiverDataServerRequest* request, + const GenericNetworkResponse* response)); Error SendResponseAndSlotData(const ReceiverDataServerRequest* request, const GenericNetworkResponse* response, - const CacheMeta* cache_slot) const noexcept override { + const CacheMeta* cache_slot) override { return Error{SendResponseAndSlotData_t(request, response, cache_slot)}; }; - MOCK_CONST_METHOD3(SendResponseAndSlotData_t, ErrorInterface * (const ReceiverDataServerRequest* request, - const GenericNetworkResponse* response, - const CacheMeta* cache_slot)); + MOCK_METHOD3(SendResponseAndSlotData_t, ErrorInterface * (const ReceiverDataServerRequest* request, + const GenericNetworkResponse* response, + const CacheMeta* cache_slot)); - void HandleAfterError(uint64_t source_id) const noexcept override { + void HandleAfterError(uint64_t source_id) override { HandleAfterError_t(source_id); } - MOCK_CONST_METHOD1(HandleAfterError_t, void (uint64_t source_id)); + MOCK_METHOD1(HandleAfterError_t, void (uint64_t source_id)); }; class MockPool : public RequestPool { -- GitLab