summaryrefslogtreecommitdiffstats
path: root/config/src/vespa
diff options
context:
space:
mode:
Diffstat (limited to 'config/src/vespa')
-rw-r--r--config/src/vespa/config/frt/frtsource.cpp39
-rw-r--r--config/src/vespa/config/frt/frtsource.h7
2 files changed, 14 insertions, 32 deletions
diff --git a/config/src/vespa/config/frt/frtsource.cpp b/config/src/vespa/config/frt/frtsource.cpp
index 11839ac0b50..1cb514dcd4d 100644
--- a/config/src/vespa/config/frt/frtsource.cpp
+++ b/config/src/vespa/config/frt/frtsource.cpp
@@ -35,9 +35,9 @@ FRTSource::FRTSource(std::shared_ptr<ConnectionFactory> connectionFactory, const
: _connectionFactory(std::move(connectionFactory)),
_requestFactory(requestFactory),
_agent(std::move(agent)),
+ _currentRequest(),
_key(key),
_lock(),
- _inflight(),
_task(std::make_unique<GetConfigTask>(_connectionFactory->getScheduler(), this)),
_closed(false)
{
@@ -66,10 +66,8 @@ FRTSource::getConfig()
std::unique_ptr<FRTConfigRequest> request = _requestFactory.createConfigRequest(_key, connection, state, serverTimeout);
FRT_RPCRequest * req = request->getRequest();
- {
- std::lock_guard guard(_lock);
- _inflight[req] = std::move(request);
- }
+
+ _currentRequest = std::move(request);
connection->invoke(req, clientTimeout, this);
}
@@ -81,24 +79,13 @@ FRTSource::RequestDone(FRT_RPCRequest * request)
LOG(debug, "request aborted, stopping");
return;
}
- std::shared_ptr<FRTConfigRequest> configRequest;
- {
- std::lock_guard guard(_lock);
- auto found = _inflight.find(request);
- assert(found != _inflight.end());
- configRequest = found->second;
- }
+ assert(_currentRequest);
// 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();
+ _currentRequest->setError(request->GetErrorCode());
}
+ _agent->handleResponse(*_currentRequest, _currentRequest->createResponse(request));
LOG(spam, "Calling schedule");
scheduleNextGetConfig();
}
@@ -106,23 +93,19 @@ FRTSource::RequestDone(FRT_RPCRequest * request)
void
FRTSource::close()
{
- RequestMap inflight;
{
std::lock_guard guard(_lock);
if (_closed)
return;
LOG(spam, "Killing task");
_task->Kill();
- inflight = _inflight;
}
LOG(spam, "Aborting");
- for (auto & request : inflight) {
- std::move(request.second)->abort();
- }
- inflight.clear();
- LOG(spam, "Waiting");
- std::unique_lock guard(_lock);
- while (!_inflight.empty()) _cond.wait(guard);
+ if (_currentRequest.get() != NULL)
+ _currentRequest->abort();
+ LOG(spam, "Syncing");
+ _connectionFactory->syncTransport();
+ _currentRequest.reset(0);
LOG(spam, "closed");
}
diff --git a/config/src/vespa/config/frt/frtsource.h b/config/src/vespa/config/frt/frtsource.h
index 104b7318d8d..1885aa7e534 100644
--- a/config/src/vespa/config/frt/frtsource.h
+++ b/config/src/vespa/config/frt/frtsource.h
@@ -29,14 +29,13 @@ public:
private:
void scheduleNextGetConfig();
- using RequestMap = std::map<FRT_RPCRequest *, std::shared_ptr<FRTConfigRequest>>;
std::shared_ptr<ConnectionFactory> _connectionFactory;
const FRTConfigRequestFactory & _requestFactory;
std::unique_ptr<ConfigAgent> _agent;
+ std::unique_ptr<FRTConfigRequest> _currentRequest;
const ConfigKey _key;
- std::mutex _lock; // Protects _inflight, _task and _closed
- std::condition_variable _cond;
- RequestMap _inflight;
+
+ std::mutex _lock; // Protects _task and _closed
std::unique_ptr<FNET_Task> _task;
bool _closed;
};