summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-11-14 14:43:04 +0100
committerGitHub <noreply@github.com>2017-11-14 14:43:04 +0100
commit9e0809b2b1a2bdb94740cba278b85a402ab6f691 (patch)
tree7a9b43fb8de31d280e663956a730e07f444c4938 /searchcore
parentdcd3a76039158c0ad29cb7ee722a4814e744384a (diff)
parent2a3a4975c81693dbfe9f51b969959e1e50338d7e (diff)
Merge pull request #4116 from vespa-engine/balder/simplify-and-always-hold-lock-on-map
Always hold the lock when accessing the handler map.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
index 560510ce744..cda1d0103c7 100644
--- a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
+++ b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "summaryengine.h"
-#include <vespa/vespalib/util/exceptions.h>
#include <vespa/log/log.h>
LOG_SETUP(".proton.summaryengine.summaryengine");
@@ -17,9 +16,7 @@ private:
DocsumRequest::Source _request;
public:
- DocsumTask(SummaryEngine & engine,
- DocsumRequest::Source request,
- DocsumClient & client)
+ DocsumTask(SummaryEngine & engine, DocsumRequest::Source request, DocsumClient & client)
: _engine(engine),
_client(client),
_request(std::move(request))
@@ -62,8 +59,7 @@ SummaryEngine::close()
}
ISearchHandler::SP
-SummaryEngine::putSearchHandler(const DocTypeName &docTypeName,
- const ISearchHandler::SP & searchHandler)
+SummaryEngine::putSearchHandler(const DocTypeName &docTypeName, const ISearchHandler::SP & searchHandler)
{
vespalib::LockGuard guard(_lock);
return _handlers.putHandler(docTypeName, searchHandler);
@@ -72,6 +68,7 @@ SummaryEngine::putSearchHandler(const DocTypeName &docTypeName,
ISearchHandler::SP
SummaryEngine::getSearchHandler(const DocTypeName &docTypeName)
{
+ vespalib::LockGuard guard(_lock);
return _handlers.getHandler(docTypeName);
}
@@ -101,17 +98,11 @@ SummaryEngine::getDocsums(DocsumRequest::Source request, DocsumClient & client)
DocsumReply::UP
SummaryEngine::getDocsums(DocsumRequest::UP req)
{
- DocsumReply::UP reply;
- reply.reset(new DocsumReply());
+ DocsumReply::UP reply = std::make_unique<DocsumReply>();
if (req) {
- ISearchHandler::SP searchHandler;
- { // try to find the summary handler corresponding to the specified search doc type
- vespalib::LockGuard guard(_lock);
- DocTypeName docTypeName(*req);
- searchHandler = _handlers.getHandler(docTypeName);
- }
- if (searchHandler.get() != NULL) {
+ ISearchHandler::SP searchHandler = getSearchHandler(DocTypeName(*req));
+ if (searchHandler) {
reply = searchHandler->getDocsums(*req);
} else {
vespalib::Sequence<ISearchHandler*>::UP snapshot;