From f3956e6144fdb4fc05b4d61cab45b77a89dca48a Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 20 Dec 2022 06:40:17 +0000 Subject: Also drop aborted requests. --- config/src/vespa/config/frt/frtsource.cpp | 33 +++++++++++++++++++------------ config/src/vespa/config/frt/frtsource.h | 2 ++ 2 files changed, 22 insertions(+), 13 deletions(-) (limited to 'config/src') diff --git a/config/src/vespa/config/frt/frtsource.cpp b/config/src/vespa/config/frt/frtsource.cpp index 11839ac0b50..ea0b514e168 100644 --- a/config/src/vespa/config/frt/frtsource.cpp +++ b/config/src/vespa/config/frt/frtsource.cpp @@ -73,32 +73,37 @@ FRTSource::getConfig() connection->invoke(req, clientTimeout, this); } +void +FRTSource::erase(FRT_RPCRequest * request) { + std::lock_guard guard(_lock); + _inflight.erase(request); + _cond.notify_all(); +} + +std::shared_ptr +FRTSource::find(FRT_RPCRequest * request) { + std::lock_guard guard(_lock); + auto found = _inflight.find(request); + assert(found != _inflight.end()); + return found->second; +} void FRTSource::RequestDone(FRT_RPCRequest * request) { if (request->GetErrorCode() == FRTE_RPC_ABORT) { LOG(debug, "request aborted, stopping"); + erase(request); return; } - std::shared_ptr configRequest; - { - std::lock_guard guard(_lock); - auto found = _inflight.find(request); - assert(found != _inflight.end()); - configRequest = found->second; - } + std::shared_ptr configRequest = find(request); // If this was error from FRT side and nothing to do with config, notify // connection about the error. if (request->IsError()) { configRequest->setError(request->GetErrorCode()); } _agent->handleResponse(*configRequest, configRequest->createResponse(request)); - { - std::lock_guard guard(_lock); - _inflight.erase(request); - _cond.notify_all(); - } + erase(request); LOG(spam, "Calling schedule"); scheduleNextGetConfig(); } @@ -122,7 +127,9 @@ FRTSource::close() inflight.clear(); LOG(spam, "Waiting"); std::unique_lock guard(_lock); - while (!_inflight.empty()) _cond.wait(guard); + while (!_inflight.empty()) { + _cond.wait(guard); + } LOG(spam, "closed"); } diff --git a/config/src/vespa/config/frt/frtsource.h b/config/src/vespa/config/frt/frtsource.h index 104b7318d8d..8bc654dd05a 100644 --- a/config/src/vespa/config/frt/frtsource.h +++ b/config/src/vespa/config/frt/frtsource.h @@ -28,6 +28,8 @@ public: void getConfig() override; private: void scheduleNextGetConfig(); + void erase(FRT_RPCRequest *); + std::shared_ptr find(FRT_RPCRequest *); using RequestMap = std::map>; std::shared_ptr _connectionFactory; -- cgit v1.2.3