diff options
169 files changed, 584 insertions, 539 deletions
diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp index 2a8a66f41d9..342b2b497bb 100644 --- a/config/src/apps/vespa-get-config/getconfig.cpp +++ b/config/src/apps/vespa-get-config/getconfig.cpp @@ -239,7 +239,7 @@ GetConfig::Main() printf("configID %s\n", rKey.getConfigId().c_str()); printf("configMD5 %s\n", rState.md5.c_str()); - printf("generation %" PRId64 "\n", rState.generation); + printf("generation %ld\n", rState.generation); printf("trace %s\n", response->getTrace().toString().c_str()); } else if (traceLevel > 0) { printf("trace %s\n", response->getTrace().toString().c_str()); diff --git a/config/src/tests/configgen/value_converter.cpp b/config/src/tests/configgen/value_converter.cpp index 1034d0821fd..8c969b77271 100644 --- a/config/src/tests/configgen/value_converter.cpp +++ b/config/src/tests/configgen/value_converter.cpp @@ -3,6 +3,7 @@ #include <vespa/config/configgen/value_converter.h> #include <vespa/config/common/exceptions.h> #include <vespa/vespalib/data/slime/slime.h> +#include <climits> using namespace config; using namespace config::internal; diff --git a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp index c14cdbbbc23..79ec1ee42f4 100644 --- a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp +++ b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp @@ -5,6 +5,7 @@ #include <vespa/fnet/frt/error.h> #include <sstream> #include <set> +#include <unistd.h> using namespace config; diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp index 7fe87775f74..257e131534b 100644 --- a/config/src/tests/functiontest/functiontest.cpp +++ b/config/src/tests/functiontest/functiontest.cpp @@ -37,8 +37,8 @@ checkVariableAccess(const FunctionTestConfig & config) EXPECT_EQUAL(1u, config.boolarr.size()); EXPECT_EQUAL(0u, config.intarr.size()); EXPECT_EQUAL(2u, config.longarr.size()); - LOG(error, "0: %" PRId64, config.longarr[0]); - LOG(error, "1: %" PRId64, config.longarr[1]); + LOG(error, "0: %ld", config.longarr[0]); + LOG(error, "1: %ld", config.longarr[1]); EXPECT_EQUAL(std::numeric_limits<int64_t>::max(), config.longarr[0]); EXPECT_EQUAL(std::numeric_limits<int64_t>::min(), config.longarr[1]); EXPECT_EQUAL(2u, config.doublearr.size()); diff --git a/config/src/tests/misc/configsystem.cpp b/config/src/tests/misc/configsystem.cpp index f0f526265ca..9574d9d274a 100644 --- a/config/src/tests/misc/configsystem.cpp +++ b/config/src/tests/misc/configsystem.cpp @@ -3,6 +3,7 @@ #include <vespa/config/common/configsystem.h> #include <vespa/defaults.h> #include <vespa/fastos/file.h> +#include <unistd.h> using namespace config; diff --git a/config/src/tests/print/print.cpp b/config/src/tests/print/print.cpp index e058b91822e..9df4bcf4914 100644 --- a/config/src/tests/print/print.cpp +++ b/config/src/tests/print/print.cpp @@ -8,6 +8,7 @@ #include <vespa/config/helper/configgetter.hpp> #include "config-my.h" #include "config-motd.h" +#include <sys/stat.h> using namespace config; diff --git a/config/src/vespa/config/common/configvalue.h b/config/src/vespa/config/common/configvalue.h index 53780dce533..7bbd48df258 100644 --- a/config/src/vespa/config/common/configvalue.h +++ b/config/src/vespa/config/common/configvalue.h @@ -1,17 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <vespa/config/frt/protocol.h> +#include <vespa/config/configgen/configpayload.h> #include <vespa/vespalib/stllike/string.h> #include <vector> #include <memory> -#include <vespa/config/frt/protocol.h> -#include <vespa/config/configgen/configpayload.h> +#include <climits> -namespace vespalib { - namespace slime { - class Cursor; - } -} +namespace vespalib::slime { class Cursor; } namespace config { diff --git a/config/src/vespa/config/frt/frtconfigagent.cpp b/config/src/vespa/config/frt/frtconfigagent.cpp index d5c662d1bda..ff16ef77a1b 100644 --- a/config/src/vespa/config/frt/frtconfigagent.cpp +++ b/config/src/vespa/config/frt/frtconfigagent.cpp @@ -26,7 +26,7 @@ FRTConfigAgent::handleResponse(const ConfigRequest & request, ConfigResponse::UP { if (LOG_WOULD_LOG(spam)) { const ConfigKey & key(request.getKey()); - LOG(spam, "current state for %s: generation %" PRId64 " md5 %s", key.toString().c_str(), _configState.generation, _configState.md5.c_str()); + LOG(spam, "current state for %s: generation %ld md5 %s", key.toString().c_str(), _configState.generation, _configState.md5.c_str()); } if (response->validateResponse() && !response->isError()) { handleOKResponse(std::move(response)); @@ -57,7 +57,7 @@ void FRTConfigAgent::handleUpdatedGeneration(const ConfigKey & key, const ConfigState & newState, const ConfigValue & configValue) { if (LOG_WOULD_LOG(spam)) { - LOG(spam, "new generation %" PRId64 " for key %s", newState.generation, key.toString().c_str()); + LOG(spam, "new generation %ld for key %s", newState.generation, key.toString().c_str()); } _configState.generation = newState.generation; bool hasDifferentPayload = newState.hasDifferentPayloadFrom(_configState); @@ -84,7 +84,7 @@ FRTConfigAgent::handleErrorResponse(const ConfigRequest & request, ConfigRespons setWaitTime(_numConfigured > 0 ? _timingValues.configuredErrorDelay : _timingValues.unconfiguredDelay, multiplier); _nextTimeout = _timingValues.errorTimeout; const ConfigKey & key(request.getKey()); - LOG(info, "Error response or no response from config server (key: %s) (errcode=%d, validresponse:%d), trying again in %" PRId64 " milliseconds", key.toString().c_str(), response->errorCode(), response->hasValidResponse() ? 1 : 0, _waitTime); + LOG(info, "Error response or no response from config server (key: %s) (errcode=%d, validresponse:%d), trying again in %ld milliseconds", key.toString().c_str(), response->errorCode(), response->hasValidResponse() ? 1 : 0, _waitTime); } void @@ -92,7 +92,7 @@ FRTConfigAgent::setWaitTime(uint64_t delay, int multiplier) { uint64_t prevWait = _waitTime; _waitTime = _timingValues.fixedDelay + (multiplier * delay); - LOG(spam, "Adjusting waittime from %" PRId64 " to %" PRId64, prevWait, _waitTime); + LOG(spam, "Adjusting waittime from %ld to %ld", prevWait, _waitTime); } uint64_t FRTConfigAgent::getTimeout() const { return _nextTimeout; } diff --git a/config/src/vespa/config/subscription/configsubscriptionset.cpp b/config/src/vespa/config/subscription/configsubscriptionset.cpp index 170bacf104d..51c29823664 100644 --- a/config/src/vespa/config/subscription/configsubscriptionset.cpp +++ b/config/src/vespa/config/subscription/configsubscriptionset.cpp @@ -67,7 +67,7 @@ ConfigSubscriptionSet::acquireSnapshot(uint64_t timeoutInMillis, bool ignoreChan } else { LOG(spam, "Config subscription did not change, id(%s), defname(%s)", key.getConfigId().c_str(), key.getDefName().c_str()); } - LOG(spam, "Previous generation is %" PRId64 ", updates is %" PRId64, generation, subscription->getGeneration()); + LOG(spam, "Previous generation is %ld, updates is %ld", generation, subscription->getGeneration()); if (isGenerationNewer(subscription->getGeneration(), _currentGeneration)) { numGenerationChanged++; } @@ -88,7 +88,7 @@ ConfigSubscriptionSet::acquireSnapshot(uint64_t timeoutInMillis, bool ignoreChan bool updated = inSync && isGenerationNewer(lastGeneration, _currentGeneration); if (updated) { - LOG(spam, "Config was updated from %" PRId64 " to %" PRId64, _currentGeneration, lastGeneration); + LOG(spam, "Config was updated from %ld to %ld", _currentGeneration, lastGeneration); _currentGeneration = lastGeneration; _state = CONFIGURED; for (SubscriptionList::iterator it(_subscriptionList.begin()), mt(_subscriptionList.end()); diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp index de03f34c5ed..1075bc4d7ce 100644 --- a/configd/src/apps/sentinel/config-handler.cpp +++ b/configd/src/apps/sentinel/config-handler.cpp @@ -6,6 +6,8 @@ #include <vespa/vespalib/net/simple_metric_snapshot.h> #include <vespa/vespalib/net/socket_address.h> +#include <fcntl.h> +#include <sys/wait.h> #include <vespa/log/log.h> LOG_SETUP(".config-handler"); diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp index 32503ac0bd0..44cff2c80de 100644 --- a/document/src/tests/documenttestcase.cpp +++ b/document/src/tests/documenttestcase.cpp @@ -13,6 +13,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/document/util/serializableexceptions.h> #include <vespa/document/util/bytebuffer.h> +#include <fcntl.h> using vespalib::nbostream; diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index 2324d21cd24..b6aca1ec8be 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -25,6 +25,8 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/exception.h> +#include <fcntl.h> +#include <unistd.h> using namespace document::config_builder; using vespalib::tensor::Tensor; diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp index fc94c5e63eb..70f16eccfe1 100644 --- a/document/src/tests/fieldpathupdatetestcase.cpp +++ b/document/src/tests/fieldpathupdatetestcase.cpp @@ -13,7 +13,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/document/serialization/vespadocumentserializer.h> #include <vespa/vespalib/objects/nbostream.h> - +#include <fcntl.h> using vespalib::Identifiable; using namespace document::config_builder; diff --git a/document/src/tests/predicate/predicate_test.cpp b/document/src/tests/predicate/predicate_test.cpp index e8db197fdad..6da866cb154 100644 --- a/document/src/tests/predicate/predicate_test.cpp +++ b/document/src/tests/predicate/predicate_test.cpp @@ -1,15 +1,16 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // Unit tests for predicate. -#include <vespa/log/log.h> -LOG_SETUP("predicate_test"); - #include <vespa/document/predicate/predicate.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/document/predicate/predicate_slime_builder.h> #include <string> +#include <climits> + +#include <vespa/log/log.h> +LOG_SETUP("predicate_test"); using std::string; using std::vector; diff --git a/document/src/vespa/document/predicate/predicate.cpp b/document/src/vespa/document/predicate/predicate.cpp index 3e44cd649b7..df4128246a9 100644 --- a/document/src/vespa/document/predicate/predicate.cpp +++ b/document/src/vespa/document/predicate/predicate.cpp @@ -3,6 +3,7 @@ #include "predicate.h" #include <vespa/vespalib/data/slime/slime.h> #include <set> +#include <climits> using std::mismatch; using std::pair; diff --git a/documentapi/src/tests/messages/messages50test.h b/documentapi/src/tests/messages/messages50test.h index 642dad8d734..8711264ee7a 100644 --- a/documentapi/src/tests/messages/messages50test.h +++ b/documentapi/src/tests/messages/messages50test.h @@ -6,7 +6,7 @@ class Messages50Test : public TestBase { protected: const vespalib::Version getVersion() const override { return vespalib::Version(5, 0); } - bool shouldTestCoverage() const override { return FALSE; } + bool shouldTestCoverage() const override { return false; } bool tryDocumentReply(const string &filename, uint32_t type); bool tryVisitorReply(const string &filename, uint32_t type); diff --git a/documentapi/src/tests/messages/messages51test.h b/documentapi/src/tests/messages/messages51test.h index 6ad1573f4f5..897491af892 100644 --- a/documentapi/src/tests/messages/messages51test.h +++ b/documentapi/src/tests/messages/messages51test.h @@ -6,7 +6,7 @@ class Messages51Test : public Messages50Test { protected: const vespalib::Version getVersion() const override { return vespalib::Version(5, 1); } - bool shouldTestCoverage() const override { return TRUE; } + bool shouldTestCoverage() const override { return true; } public: Messages51Test(); diff --git a/documentapi/src/tests/messages/testbase.cpp b/documentapi/src/tests/messages/testbase.cpp index c36faa251ab..995fde4aa69 100644 --- a/documentapi/src/tests/messages/testbase.cpp +++ b/documentapi/src/tests/messages/testbase.cpp @@ -4,6 +4,9 @@ #include <vespa/document/base/testdocrepo.h> #include <vespa/vespalib/util/exception.h> #include <vespa/log/log.h> +#include <fcntl.h> +#include <unistd.h> + LOG_SETUP(".testbase"); using document::DocumentTypeRepo; diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp index ca698f4ae3a..b3e6ac422eb 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "visitor.h" +#include <climits> namespace documentapi { diff --git a/fastlib/src/vespa/fastlib/io/bufferedfile.cpp b/fastlib/src/vespa/fastlib/io/bufferedfile.cpp index 26c75cc1fb1..6a50cfe2259 100644 --- a/fastlib/src/vespa/fastlib/io/bufferedfile.cpp +++ b/fastlib/src/vespa/fastlib/io/bufferedfile.cpp @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "bufferedfile.h" +#include <cassert> +#include <cstring> namespace { diff --git a/fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp b/fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp index c67a513c67b..f9957d96288 100644 --- a/fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp +++ b/fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp @@ -2,6 +2,7 @@ #include <cassert> #include <ctime> #include <iostream> +#include <cstring> using namespace std; diff --git a/fastlib/src/vespa/fastlib/net/httpserver.cpp b/fastlib/src/vespa/fastlib/net/httpserver.cpp index cd3b7705cff..807b169323d 100644 --- a/fastlib/src/vespa/fastlib/net/httpserver.cpp +++ b/fastlib/src/vespa/fastlib/net/httpserver.cpp @@ -10,6 +10,7 @@ #include <vespa/fastlib/util/base64.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/fastos/file.h> +#include <cassert> /** * Helper class for hiding the details of HTTP entity encodings and diff --git a/fastlib/src/vespa/fastlib/text/normwordfolder.cpp b/fastlib/src/vespa/fastlib/text/normwordfolder.cpp index 208bf9c8cb1..767431e5531 100644 --- a/fastlib/src/vespa/fastlib/text/normwordfolder.cpp +++ b/fastlib/src/vespa/fastlib/text/normwordfolder.cpp @@ -3,6 +3,7 @@ #include <vespa/fastlib/text/unicodeutil.h> #include <vespa/fastlib/text/normwordfolder.h> #include <vespa/fastos/mutex.h> +#include <cstring> bool Fast_NormalizeWordFolder::_isInitialized = false; FastOS_Mutex _initMutex; diff --git a/fastlib/src/vespa/fastlib/util/tests/base64test.cpp b/fastlib/src/vespa/fastlib/util/tests/base64test.cpp index accf7fc87b3..16bb3ccd9ad 100644 --- a/fastlib/src/vespa/fastlib/util/tests/base64test.cpp +++ b/fastlib/src/vespa/fastlib/util/tests/base64test.cpp @@ -3,6 +3,7 @@ #include <vespa/fastos/file.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/fastlib/util/base64.h> +#include <cassert> class Base64Test : public FastOS_Application { public: diff --git a/fastos/src/tests/filetest.cpp b/fastos/src/tests/filetest.cpp index 92fd5558590..ad411364c0c 100644 --- a/fastos/src/tests/filetest.cpp +++ b/fastos/src/tests/filetest.cpp @@ -3,6 +3,8 @@ #include "tests.h" #include <vespa/fastos/file.h> #include <memory> +#include <cassert> +#include <sys/mman.h> namespace { diff --git a/fastos/src/tests/sockettest.cpp b/fastos/src/tests/sockettest.cpp index 3a62fdbf6eb..0b6e8c9360d 100644 --- a/fastos/src/tests/sockettest.cpp +++ b/fastos/src/tests/sockettest.cpp @@ -3,7 +3,7 @@ #include "tests.h" #include <vespa/fastos/file.h> #include <vespa/fastos/serversocket.h> - +#include <cassert> #define MAZE_FILE_OFFSET 1078 diff --git a/fastos/src/tests/tests.h b/fastos/src/tests/tests.h index 94062c04e54..62a873f8a54 100644 --- a/fastos/src/tests/tests.h +++ b/fastos/src/tests/tests.h @@ -3,6 +3,7 @@ #include <vespa/fastos/app.h> #include <vespa/fastos/socket.h> #include <vespa/fastos/thread.h> +#include <cstring> class BaseTest : public FastOS_Application { diff --git a/fastos/src/tests/typetest.cpp b/fastos/src/tests/typetest.cpp index e0399b56ba5..87e3d76c461 100644 --- a/fastos/src/tests/typetest.cpp +++ b/fastos/src/tests/typetest.cpp @@ -9,40 +9,6 @@ class TypeTest : public BaseTest { private: - void PrintfSpecifiersTest () - { - char testBuf[200]; - const char *correct; - - TestHeader("64-bit printf-specifiers test"); - - sprintf(testBuf, "%" PRId64, int64_t(-1000)*1000*1000*1000*1000); - correct = "-1000000000000000"; - Progress(strcmp(testBuf, correct) == 0, - "Generated=[%s], Correct=[%s]", testBuf, correct); - - sprintf(testBuf, "%" PRIu64, uint64_t(1000)*1000*1000*1000*1000); - correct = "1000000000000000"; - Progress(strcmp(testBuf, correct) == 0, - "Generated=[%s], Correct=[%s]", testBuf, correct); - - sprintf(testBuf, "%" PRIo64, uint64_t(1000)*1000*1000*1000*1000); - correct = "34327724461500000"; - Progress(strcmp(testBuf, correct) == 0, - "Generated=[%s], Correct=[%s]", testBuf, correct); - - sprintf(testBuf, "%" PRIx64, uint64_t(1000)*1000*1000*1000*1000); - correct = "38d7ea4c68000"; - Progress(strcmp(testBuf, correct) == 0, - "Generated=[%s], Correct=[%s]", testBuf, correct); - - sprintf(testBuf, "%" PRIX64, uint64_t(1000)*1000*1000*1000*1000); - correct = "38D7EA4C68000"; - Progress(strcmp(testBuf, correct) == 0, - "Generated=[%s], Correct=[%s]", testBuf, correct); - - PrintSeparator(); - } void ObjectSizeTest () { @@ -73,7 +39,6 @@ public: { printf("grep for the string '%s' to detect failures.\n\n", failString); - PrintfSpecifiersTest(); ObjectSizeTest(); PrintSeparator(); diff --git a/fastos/src/vespa/fastos/CMakeLists.txt b/fastos/src/vespa/fastos/CMakeLists.txt index 661dd1c6547..2a0ff2d370a 100644 --- a/fastos/src/vespa/fastos/CMakeLists.txt +++ b/fastos/src/vespa/fastos/CMakeLists.txt @@ -5,6 +5,7 @@ vespa_add_library(fastos_objects OBJECT backtrace.c file.cpp linux_file.cpp + process.cpp serversocket.cpp socket.cpp socketevent.cpp diff --git a/fastos/src/vespa/fastos/app.cpp b/fastos/src/vespa/fastos/app.cpp index a76cd64d197..079dab55754 100644 --- a/fastos/src/vespa/fastos/app.cpp +++ b/fastos/src/vespa/fastos/app.cpp @@ -6,12 +6,14 @@ * @author Div, Oivind H. Danielsen */ -#include <vespa/fastos/app.h> -#include <vespa/fastos/socket.h> -#include <vespa/fastos/file.h> - -#include <vespa/fastos/process.h> -#include <vespa/fastos/thread.h> +#include "app.h" +#include "socket.h" +#include "file.h" + +#include "process.h" +#include "thread.h" +#include <cstring> +#include <fcntl.h> FastOS_ApplicationInterface *FastOS_ProcessInterface::_app; FastOS_ThreadPool *FastOS_ProcessInterface::GetThreadPool () diff --git a/fastos/src/vespa/fastos/cond.h b/fastos/src/vespa/fastos/cond.h index 457abe666d4..c9405728223 100644 --- a/fastos/src/vespa/fastos/cond.h +++ b/fastos/src/vespa/fastos/cond.h @@ -9,9 +9,7 @@ #pragma once - -#include <vespa/fastos/types.h> -#include <vespa/fastos/mutex.h> +#include "mutex.h" /** diff --git a/fastos/src/vespa/fastos/file.cpp b/fastos/src/vespa/fastos/file.cpp index cf17b672bd5..8f164c2a522 100644 --- a/fastos/src/vespa/fastos/file.cpp +++ b/fastos/src/vespa/fastos/file.cpp @@ -6,9 +6,10 @@ * @author Div, Oivind H. Danielsen */ -#include <vespa/fastos/file.h> +#include "file.h" #include <sstream> - +#include <cstring> +#include <fcntl.h> DirectIOException::DirectIOException(const char * fileName, const void * buffer, size_t length, int64_t offset) : std::exception(), @@ -495,3 +496,18 @@ bool FastOS_FileInterface::Rename (const char *newFileName) void FastOS_FileInterface::dropFromCache() const { } + +FastOS_DirectoryScanInterface::FastOS_DirectoryScanInterface(const char *path) + : _searchPath(strdup(path)) +{ +} + +/** + * Destructor. + * + * Frees operating system resources related to the directory scan. + */ +FastOS_DirectoryScanInterface::~FastOS_DirectoryScanInterface() +{ + free(_searchPath); +}
\ No newline at end of file diff --git a/fastos/src/vespa/fastos/file.h b/fastos/src/vespa/fastos/file.h index 8a9de224259..00ba61b793f 100644 --- a/fastos/src/vespa/fastos/file.h +++ b/fastos/src/vespa/fastos/file.h @@ -115,13 +115,6 @@ public: int getFAdviseOptions() const { return _fAdviseOptions; } void setFAdviseOptions(int options) { _fAdviseOptions = options; } - char *ToString () { - const char dummy[]="FastOS_File::ToString() deprecated"; - char *str = new char [strlen(dummy) + 1]; - strcpy(str, dummy); - return str; - } - /** * Initialize the file class. This is invoked by * @ref FastOS_Application::Init(). @@ -752,20 +745,14 @@ public: * @param path Path of the directory to be scanned. The path string * is copied internally. */ - FastOS_DirectoryScanInterface(const char *path) - : _searchPath(strdup(path)) - { - } + FastOS_DirectoryScanInterface(const char *path); /** * Destructor. * * Frees operating system resources related to the directory scan. */ - virtual ~FastOS_DirectoryScanInterface() - { - free(_searchPath); - } + virtual ~FastOS_DirectoryScanInterface(); /** * Get search path. diff --git a/fastos/src/vespa/fastos/linux_file.cpp b/fastos/src/vespa/fastos/linux_file.cpp index 1b9556569e2..3817e337490 100644 --- a/fastos/src/vespa/fastos/linux_file.cpp +++ b/fastos/src/vespa/fastos/linux_file.cpp @@ -7,9 +7,10 @@ * Implementation of FastOS_Linux_File methods. *****************************************************************************/ -#include <vespa/fastos/file.h> +#include "file.h" #include <sstream> -#include <stdexcept> +#include <unistd.h> +#include <fcntl.h> const size_t FastOS_Linux_File::_directIOFileAlign = 4096; const size_t FastOS_Linux_File::_directIOMemAlign = 4096; diff --git a/fastos/src/vespa/fastos/mutex.h b/fastos/src/vespa/fastos/mutex.h index 011340b46ca..530e8d007bc 100644 --- a/fastos/src/vespa/fastos/mutex.h +++ b/fastos/src/vespa/fastos/mutex.h @@ -9,8 +9,7 @@ #pragma once -#include <vespa/fastos/types.h> - +#include "types.h" /** * This class defines a mutual-exclusion object. @@ -31,7 +30,7 @@ public: /** * Destructor */ - virtual ~FastOS_MutexInterface () {}; + virtual ~FastOS_MutexInterface () {} /** * Obtain an exclusive lock on the mutex. The result of a recursive lock @@ -42,7 +41,7 @@ public: * * Use @ref Unlock() to unlock the mutex when done. */ - virtual void Lock (void)=0; + virtual void Lock ()=0; /** * Try to obtain an exclusive lock on the mutex. If a lock cannot be @@ -51,15 +50,15 @@ public: * the mutex was locked in the attempt, true is returned. * @return Boolean success/failure */ - virtual bool TryLock (void)=0; + virtual bool TryLock ()=0; /** * Unlock a locked mutex. The result of unlocking a mutex not already * locked by the calling thread is undefined. */ - virtual void Unlock (void)=0; + virtual void Unlock ()=0; }; -#include <vespa/fastos/unix_mutex.h> +#include "unix_mutex.h" typedef FastOS_UNIX_Mutex FASTOS_PREFIX(Mutex); diff --git a/fastos/src/vespa/fastos/process.h b/fastos/src/vespa/fastos/process.h index 62578f97e44..e29b90d49cd 100644 --- a/fastos/src/vespa/fastos/process.h +++ b/fastos/src/vespa/fastos/process.h @@ -10,7 +10,7 @@ #pragma once -#include <vespa/fastos/types.h> +#include "types.h" /** * This class serves as a sink for redirected (piped) output from @@ -112,27 +112,13 @@ public: bool pipeStdin = false, FastOS_ProcessRedirectListener *stdoutListener = NULL, FastOS_ProcessRedirectListener *stderrListener = NULL, - int bufferSize = 65535) : - _extradoublehackforalignment(0.0), - _cmdLine(NULL), - _pipeStdin(pipeStdin), - _stdoutListener(stdoutListener), - _stderrListener(stderrListener), - _bufferSize(bufferSize), - _next(NULL), - _prev(NULL) - { - _cmdLine = strdup(cmdLine); - } + int bufferSize = 65535); /** * Destructor. * If @ref Wait has not been called yet, it is called here. */ - virtual ~FastOS_ProcessInterface () - { - free (_cmdLine); - }; + virtual ~FastOS_ProcessInterface (); /** * Create and start the process. If your command line includes diff --git a/fastos/src/vespa/fastos/serversocket.cpp b/fastos/src/vespa/fastos/serversocket.cpp index 335c34a29b4..2ad8ed32bb3 100644 --- a/fastos/src/vespa/fastos/serversocket.cpp +++ b/fastos/src/vespa/fastos/serversocket.cpp @@ -6,7 +6,8 @@ * @author Div, Oivind H. Danielsen */ -#include <vespa/fastos/serversocket.h> +#include "serversocket.h" +#include <cstring> /** @@ -93,6 +94,16 @@ FastOS_Socket *FastOS_ServerSocket::AcceptPlain() return handlerSocket; } +FastOS_ServerSocket::FastOS_ServerSocket(int socketHandle, FastOS_SocketFactory *socketFactory) + : _portNumber(-1), + _backLog(-1), + _socketFactory(socketFactory), + _validAddress(false) +{ + _socketHandle = socketHandle; + memset(&_address, 0, sizeof(_address)); + _validAddress = true; +} bool FastOS_ServerSocket::Listen () { diff --git a/fastos/src/vespa/fastos/serversocket.h b/fastos/src/vespa/fastos/serversocket.h index 77e7beee55a..8452649015c 100644 --- a/fastos/src/vespa/fastos/serversocket.h +++ b/fastos/src/vespa/fastos/serversocket.h @@ -118,17 +118,7 @@ public: * @param socketHandle OS handle of supplied socket. * @param socketFactory See @ref SetSocketFactory(). */ - FastOS_ServerSocket(int socketHandle, - FastOS_SocketFactory *socketFactory) - : _portNumber(-1), - _backLog(-1), - _socketFactory(socketFactory), - _validAddress(false) - { - _socketHandle = socketHandle; - memset(&_address, 0, sizeof(_address)); - _validAddress = true; - } + FastOS_ServerSocket(int socketHandle, FastOS_SocketFactory *socketFactory); /** * Create a listening socket. This involves creating an OS diff --git a/fastos/src/vespa/fastos/socket.cpp b/fastos/src/vespa/fastos/socket.cpp index 522d39c4b32..21f5d788b18 100644 --- a/fastos/src/vespa/fastos/socket.cpp +++ b/fastos/src/vespa/fastos/socket.cpp @@ -1,7 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/socket.h> +#include "socket.h" #include <sstream> +#include <cassert> +#include <cstring> +#include <netinet/tcp.h> FastOS_SocketInterface::FastOS_SocketInterface() : _readEventEnabled(false), diff --git a/fastos/src/vespa/fastos/socketevent.cpp b/fastos/src/vespa/fastos/socketevent.cpp index 7e5164d2247..e3bc7d28888 100644 --- a/fastos/src/vespa/fastos/socketevent.cpp +++ b/fastos/src/vespa/fastos/socketevent.cpp @@ -1,7 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/socketevent.h> -#include <vespa/fastos/socket.h> +#include "socketevent.h" +#include "socket.h" +#include <cassert> +#include <unistd.h> + FastOS_SocketEventObjects *FastOS_SocketEventObjects::_objects = NULL; FastOS_Mutex FastOS_SocketEventObjects::_listMutex; diff --git a/fastos/src/vespa/fastos/socketevent.h b/fastos/src/vespa/fastos/socketevent.h index 5a1e09b1765..e7f67816586 100644 --- a/fastos/src/vespa/fastos/socketevent.h +++ b/fastos/src/vespa/fastos/socketevent.h @@ -2,8 +2,8 @@ #pragma once -#include <vespa/fastos/types.h> -#include <vespa/fastos/mutex.h> +#include "types.h" +#include "mutex.h" #include <poll.h> #include <sys/epoll.h> diff --git a/fastos/src/vespa/fastos/thread.cpp b/fastos/src/vespa/fastos/thread.cpp index ccf9b544e77..484746a9b0d 100644 --- a/fastos/src/vespa/fastos/thread.cpp +++ b/fastos/src/vespa/fastos/thread.cpp @@ -6,7 +6,9 @@ * @author Oivind H. Danielsen */ -#include <vespa/fastos/thread.h> +#include "thread.h" +#include <cstdio> +#include <cassert> // ---------------------------------------------------------------------- // FastOS_ThreadPool diff --git a/fastos/src/vespa/fastos/thread.h b/fastos/src/vespa/fastos/thread.h index 24a4b1768fc..b84708eb050 100644 --- a/fastos/src/vespa/fastos/thread.h +++ b/fastos/src/vespa/fastos/thread.h @@ -11,9 +11,9 @@ #pragma once -#include <vespa/fastos/types.h> -#include <vespa/fastos/mutex.h> -#include <vespa/fastos/cond.h> +#include "types.h" +#include "mutex.h" +#include "cond.h" typedef pthread_t FastOS_ThreadId; diff --git a/fastos/src/vespa/fastos/types.h b/fastos/src/vespa/fastos/types.h index 08ad40ac8be..506d514f642 100644 --- a/fastos/src/vespa/fastos/types.h +++ b/fastos/src/vespa/fastos/types.h @@ -28,29 +28,16 @@ #define __STDC_FORMAT_MACROS #endif -#include <assert.h> - -#include <pthread.h> -#include <sys/mman.h> - #ifdef __TYPES_H_PTHREAD_U98 #undef __USE_UNIX98 #endif -#include <sys/types.h> -#include <sys/uio.h> -#include <sys/param.h> -#include <sys/wait.h> -#include <sys/utsname.h> -#include <rpc/types.h> -#include <stdarg.h> -#include <ctype.h> + #ifndef __USE_UNIX98 #define __TYPES_H_UNISTD_U98 #define __USE_UNIX98 #endif -#include <unistd.h> #ifdef __TYPES_H_UNISTD_U98 #undef __USE_UNIX98 #endif @@ -74,24 +61,11 @@ #define __TYPES_H_DIRECTIO_GNU #endif -#include <fcntl.h> #ifdef __TYPES_H_DIRECTIO_GNU #undef __USE_GNU /* for O_DIRECT define */ #endif -#include <stdio.h> -#include <stdlib.h> - -#include <string.h> -#include <errno.h> -#include <sys/stat.h> -#include <limits.h> -#include <float.h> -#include <netinet/tcp.h> -#include <inttypes.h> -#include <getopt.h> - #if (__WORDSIZE == 64) #else diff --git a/fastos/src/vespa/fastos/unix_app.cpp b/fastos/src/vespa/fastos/unix_app.cpp index d52813ceb76..e736a157eb8 100644 --- a/fastos/src/vespa/fastos/unix_app.cpp +++ b/fastos/src/vespa/fastos/unix_app.cpp @@ -7,10 +7,12 @@ * Implementation of FastOS_UNIX_Application methods. *****************************************************************************/ -#include <vespa/fastos/app.h> -#include <vespa/fastos/time.h> -#include <vespa/fastos/process.h> -#include <vespa/fastos/unix_ipc.h> +#include "app.h" +#include "time.h" +#include "process.h" +#include "unix_ipc.h" +#include <unistd.h> +#include <getopt.h> FastOS_UNIX_Application::FastOS_UNIX_Application () @@ -33,6 +35,36 @@ unsigned int FastOS_UNIX_Application::GetCurrentProcessId () return static_cast<unsigned int>(getpid()); } +int +FastOS_UNIX_Application::GetOpt (const char *optionsString, + const char* &optionArgument, + int &optionIndex) +{ + optind = optionIndex; + + int rc = getopt(_argc, _argv, optionsString); + optionArgument = optarg; + optionIndex = optind; + return rc; +} + +int +FastOS_UNIX_Application::GetOptLong(const char *optionsString, + const char* &optionArgument, + int &optionIndex, + const struct option *longopts, + int *longindex) +{ + optind = optionIndex; + + int rc = getopt_long(_argc, _argv, optionsString, + longopts, + longindex); + + optionArgument = optarg; + optionIndex = optind; + return rc; +} bool FastOS_UNIX_Application:: SendIPCMessage (FastOS_UNIX_Process *xproc, const void *buffer, diff --git a/fastos/src/vespa/fastos/unix_app.h b/fastos/src/vespa/fastos/unix_app.h index db6669813cf..49a5950c433 100644 --- a/fastos/src/vespa/fastos/unix_app.h +++ b/fastos/src/vespa/fastos/unix_app.h @@ -9,8 +9,8 @@ #pragma once -#include <vespa/fastos/types.h> -#include <vespa/fastos/app.h> +#include "types.h" +#include "app.h" class FastOS_UNIX_ProcessStarter; class FastOS_UNIX_IPCHelper; @@ -34,34 +34,10 @@ public: FastOS_UNIX_Application (); virtual ~FastOS_UNIX_Application(); - int GetOpt (const char *optionsString, - const char* &optionArgument, - int &optionIndex) - { - optind = optionIndex; + int GetOpt (const char *optionsString, const char* &optionArgument, int &optionIndex); - int rc = getopt(_argc, _argv, optionsString); - optionArgument = optarg; - optionIndex = optind; - return rc; - } - - int GetOptLong(const char *optionsString, - const char* &optionArgument, - int &optionIndex, - const struct option *longopts, - int *longindex) - { - optind = optionIndex; - - int rc = getopt_long(_argc, _argv, optionsString, - longopts, - longindex); - - optionArgument = optarg; - optionIndex = optind; - return rc; - } + int GetOptLong(const char *optionsString, const char* &optionArgument, int &optionIndex, + const struct option *longopts, int *longindex); static unsigned int GetCurrentProcessId (); diff --git a/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp b/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp index f34bc053870..75d3ee9fb27 100644 --- a/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp +++ b/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp @@ -56,7 +56,7 @@ FastOS_UNIX_DynamicLibrary::Close() bool retcode = true; if (IsOpen()) { - retcode = (dlclose(_handle) == TRUE); + retcode = (dlclose(_handle) == 0); if (retcode) _handle = NULL; } diff --git a/fastos/src/vespa/fastos/unix_file.cpp b/fastos/src/vespa/fastos/unix_file.cpp index c4b1448c625..ac474dfcf1a 100644 --- a/fastos/src/vespa/fastos/unix_file.cpp +++ b/fastos/src/vespa/fastos/unix_file.cpp @@ -7,9 +7,15 @@ * Implementation of FastOS_UNIX_File methods. *****************************************************************************/ -#include <vespa/fastos/file.h> -#include <sys/vfs.h> +#include "file.h" #include <sstream> +#include <cassert> +#include <cstring> +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <sys/vfs.h> bool FastOS_UNIX_File::SetPosition(int64_t desiredPosition) @@ -59,6 +65,8 @@ FastOS_UNIX_File::Stat(const char *filename, FastOS_StatInfo *statInfo) return rc; } +bool FastOS_UNIX_File::SetCurrentDirectory (const char *pathName) { return (chdir(pathName) == 0); } + int FastOS_UNIX_File::GetMaximumFilenameLength (const char *pathName) { diff --git a/fastos/src/vespa/fastos/unix_file.h b/fastos/src/vespa/fastos/unix_file.h index 8ac520ccd53..3311782b47a 100644 --- a/fastos/src/vespa/fastos/unix_file.h +++ b/fastos/src/vespa/fastos/unix_file.h @@ -43,7 +43,7 @@ public: static std::string getCurrentDirectory(); - static bool SetCurrentDirectory (const char *pathName) { return (chdir(pathName) == 0); } + static bool SetCurrentDirectory (const char *pathName); static int GetMaximumFilenameLength (const char *pathName); static int GetMaximumPathLength (const char *pathName); @@ -56,7 +56,6 @@ public: _mmapEnabled(false) { } - char *ToString(); bool Open(unsigned int openFlags, const char *filename) override; bool Close() override; bool IsOpened() const override { return _filedes >= 0; } diff --git a/fastos/src/vespa/fastos/unix_ipc.cpp b/fastos/src/vespa/fastos/unix_ipc.cpp index d02bc4189ca..f8cde75bc7a 100644 --- a/fastos/src/vespa/fastos/unix_ipc.cpp +++ b/fastos/src/vespa/fastos/unix_ipc.cpp @@ -1,11 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/unix_ipc.h> - -#include <vespa/fastos/ringbuffer.h> +#include "unix_ipc.h" +#include "ringbuffer.h" +#include <cassert> +#include <cstring> +#include <unistd.h> +#include <fcntl.h> FastOS_UNIX_IPCHelper:: -FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, - int descriptor) +FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, int descriptor) : _lock(), _exitFlag(false), _app(app), diff --git a/fastos/src/vespa/fastos/unix_mutex.cpp b/fastos/src/vespa/fastos/unix_mutex.cpp index a41eb974604..4d802f691ec 100644 --- a/fastos/src/vespa/fastos/unix_mutex.cpp +++ b/fastos/src/vespa/fastos/unix_mutex.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/mutex.h> +#include "mutex.h" +#include <cassert> FastOS_UNIX_Mutex::FastOS_UNIX_Mutex(void) : FastOS_MutexInterface(), diff --git a/fastos/src/vespa/fastos/unix_mutex.h b/fastos/src/vespa/fastos/unix_mutex.h index 4a1d466e405..30150bc1590 100644 --- a/fastos/src/vespa/fastos/unix_mutex.h +++ b/fastos/src/vespa/fastos/unix_mutex.h @@ -12,8 +12,8 @@ #pragma once -#include <vespa/fastos/mutex.h> - +#include "mutex.h" +#include <pthread.h> class FastOS_UNIX_Mutex : public FastOS_MutexInterface { diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp index 6930dc0247e..f3d15561958 100644 --- a/fastos/src/vespa/fastos/unix_process.cpp +++ b/fastos/src/vespa/fastos/unix_process.cpp @@ -1,9 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/process.h> -#include <vespa/fastos/app.h> -#include <vespa/fastos/unix_ipc.h> -#include <vespa/fastos/time.h> +#include "process.h" +#include "unix_ipc.h" +#include "time.h" +#include "ringbuffer.h" #include <vector> +#include <cstring> +#include <unistd.h> +#include <fcntl.h> +#include <sys/wait.h> #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX @@ -1408,6 +1412,29 @@ bool FastOS_UNIX_ProcessStarter::CreateSocketPairs () return rc; } +FastOS_UNIX_ProcessStarter::FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app) + : _app(app), + _processList(NULL), + _pid(-1), + _starterSocket(-1), + _mainSocket(-1), + _starterSocketDescr(-1), + _mainSocketDescr(-1), + _hasProxiedChildren(false), + _closedProxyProcessFiles(false), + _hasDetachedProcess(false), + _hasDirectChildren(false) +{ +} + +FastOS_UNIX_ProcessStarter::~FastOS_UNIX_ProcessStarter () +{ + if(_starterSocket != -1) + close(_starterSocket); + if(_mainSocket != -1) + close(_mainSocket); +} + bool FastOS_UNIX_ProcessStarter::Start () { bool rc = false; @@ -1979,3 +2006,41 @@ bool FastOS_UNIX_ProcessStarter::Detach(FastOS_UNIX_Process *process) process->_app->ProcessUnlock(); return rc; } + +FastOS_UNIX_Process::DescriptorHandle::DescriptorHandle() + : _fd(-1), + _wantRead(false), + _wantWrite(false), + _canRead(false), + _canWrite(false), + _pollIdx(-1), + _readBuffer(), + _writeBuffer() +{ +} +FastOS_UNIX_Process::DescriptorHandle::~DescriptorHandle() { } +void +FastOS_UNIX_Process::DescriptorHandle::CloseHandle() +{ + _wantRead = false; + _wantWrite = false; + _canRead = false; + _canWrite = false; + _pollIdx = -1; + if (_fd != -1) { + close(_fd); + _fd = -1; + } + if (_readBuffer.get() != NULL) + _readBuffer->Close(); + if (_writeBuffer.get() != NULL) + _writeBuffer->Close(); +} +void +FastOS_UNIX_Process::DescriptorHandle::CloseHandleDirectChild() +{ + if (_fd != -1) { + close(_fd); + _fd = -1; + } +}
\ No newline at end of file diff --git a/fastos/src/vespa/fastos/unix_process.h b/fastos/src/vespa/fastos/unix_process.h index 97a5b57c08d..ff034b0e581 100644 --- a/fastos/src/vespa/fastos/unix_process.h +++ b/fastos/src/vespa/fastos/unix_process.h @@ -8,15 +8,14 @@ #pragma once -#include <vespa/fastos/process.h> -#include <vespa/fastos/app.h> +#include "process.h" +#include "app.h" #include <string> #include <memory> class FastOS_BoolCond; class FastOS_UNIX_RealProcess; - -#include <vespa/fastos/ringbuffer.h> +class FastOS_RingBuffer; class FastOS_UNIX_Process : public FastOS_ProcessInterface { @@ -45,41 +44,10 @@ public: int _pollIdx; std::unique_ptr<FastOS_RingBuffer> _readBuffer; std::unique_ptr<FastOS_RingBuffer> _writeBuffer; - DescriptorHandle(void) - : _fd(-1), - _wantRead(false), - _wantWrite(false), - _canRead(false), - _canWrite(false), - _pollIdx(-1), - _readBuffer(), - _writeBuffer() - { - } - ~DescriptorHandle() { } - void CloseHandle(void) - { - _wantRead = false; - _wantWrite = false; - _canRead = false; - _canWrite = false; - _pollIdx = -1; - if (_fd != -1) { - close(_fd); - _fd = -1; - } - if (_readBuffer.get() != NULL) - _readBuffer->Close(); - if (_writeBuffer.get() != NULL) - _writeBuffer->Close(); - } - void CloseHandleDirectChild(void) - { - if (_fd != -1) { - close(_fd); - _fd = -1; - } - } + DescriptorHandle(); + ~DescriptorHandle(); + void CloseHandle(); + void CloseHandleDirectChild(); }; private: DescriptorHandle _descriptor[4]; @@ -95,8 +63,7 @@ private: GetProcessStarter(); } - bool InternalWait (int *returnCode, int timeOutSeconds, - bool *pollStillRunning); + bool InternalWait (int *returnCode, int timeOutSeconds, bool *pollStillRunning); public: enum DescriptorType { @@ -298,28 +265,8 @@ protected: void PollReapDirectChildren(void); public: - FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app) - : _app(app), - _processList(NULL), - _pid(-1), - _starterSocket(-1), - _mainSocket(-1), - _starterSocketDescr(-1), - _mainSocketDescr(-1), - _hasProxiedChildren(false), - _closedProxyProcessFiles(false), - _hasDetachedProcess(false), - _hasDirectChildren(false) - { - } - - ~FastOS_UNIX_ProcessStarter () - { - if(_starterSocket != -1) - close(_starterSocket); - if(_mainSocket != -1) - close(_mainSocket); - } + FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app); + ~FastOS_UNIX_ProcessStarter (); bool Start (); void Stop (); diff --git a/fastos/src/vespa/fastos/unix_socket.cpp b/fastos/src/vespa/fastos/unix_socket.cpp index ae72c39147d..2bdda49c982 100644 --- a/fastos/src/vespa/fastos/unix_socket.cpp +++ b/fastos/src/vespa/fastos/unix_socket.cpp @@ -1,6 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/socket.h> +#include "socket.h" +#include <cassert> +#include <cstring> +#include <unistd.h> +#include <fcntl.h> FastOS_UNIX_Socket::~FastOS_UNIX_Socket() { diff --git a/fastos/src/vespa/fastos/unix_thread.cpp b/fastos/src/vespa/fastos/unix_thread.cpp index 3633d1cacc6..eca7a472c6d 100644 --- a/fastos/src/vespa/fastos/unix_thread.cpp +++ b/fastos/src/vespa/fastos/unix_thread.cpp @@ -1,7 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/thread.h> +#include "thread.h" #include <atomic> #include <thread> +#include <unistd.h> namespace { std::atomic_size_t _G_nextCpuId(0); @@ -69,7 +70,7 @@ void FastOS_UNIX_Thread::PreEntry () { } -FastOS_UNIX_Thread::~FastOS_UNIX_Thread(void) +FastOS_UNIX_Thread::~FastOS_UNIX_Thread() { void *value; @@ -80,6 +81,18 @@ FastOS_UNIX_Thread::~FastOS_UNIX_Thread(void) } } +bool FastOS_UNIX_Thread::Sleep (int ms) +{ + bool rc=false; + + if (ms > 0) { + usleep(ms*1000); + rc = true; + } + + return rc; +} + FastOS_ThreadId FastOS_UNIX_Thread::GetThreadId () { return _handle; @@ -90,8 +103,7 @@ FastOS_ThreadId FastOS_UNIX_Thread::GetCurrentThreadId () return pthread_self(); } -bool FastOS_UNIX_Thread::CompareThreadIds (FastOS_ThreadId a, - FastOS_ThreadId b) +bool FastOS_UNIX_Thread::CompareThreadIds (FastOS_ThreadId a, FastOS_ThreadId b) { return (pthread_equal(a, b) != 0); } diff --git a/fastos/src/vespa/fastos/unix_thread.h b/fastos/src/vespa/fastos/unix_thread.h index 691a7909bbb..c6e0b040fc7 100644 --- a/fastos/src/vespa/fastos/unix_thread.h +++ b/fastos/src/vespa/fastos/unix_thread.h @@ -9,7 +9,7 @@ #pragma once -#include <vespa/fastos/thread.h> +#include "thread.h" class FastOS_UNIX_Thread : public FastOS_ThreadInterface { @@ -36,21 +36,9 @@ public: ~FastOS_UNIX_Thread(); - static bool Sleep (int ms) - { - bool rc=false; - - if (ms > 0) { - usleep(ms*1000); - rc = true; - } - - return rc; - } - + static bool Sleep (int ms); FastOS_ThreadId GetThreadId () override; - static bool CompareThreadIds (FastOS_ThreadId a, - FastOS_ThreadId b); + static bool CompareThreadIds (FastOS_ThreadId a, FastOS_ThreadId b); static FastOS_ThreadId GetCurrentThreadId (); }; diff --git a/fbench/src/fbench/client.cpp b/fbench/src/fbench/client.cpp index 5c828fc4282..0200ea2d067 100644 --- a/fbench/src/fbench/client.cpp +++ b/fbench/src/fbench/client.cpp @@ -1,8 +1,12 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "client.h" #include <util/timer.h> +#include <util/clientstatus.h> #include <httpclient/httpclient.h> #include <util/filereader.h> -#include "client.h" +#include <cassert> +#include <cstring> Client::Client(ClientArguments *args) : _args(args), diff --git a/fbench/src/fbench/client.h b/fbench/src/fbench/client.h index 107b4997d93..1e0b750dbb2 100644 --- a/fbench/src/fbench/client.h +++ b/fbench/src/fbench/client.h @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <util/clientstatus.h> #include <fstream> #include <atomic> #include <thread> @@ -150,6 +149,11 @@ private: ClientArguments &operator=(const ClientArguments &); }; + +class Timer; +class HTTPClient; +class FileReader; +class ClientStatus; /** * This class implements a single test client. The clients are run in * separate threads to simulate several simultanious users. The @@ -161,9 +165,9 @@ class Client private: std::unique_ptr<ClientArguments> _args; std::unique_ptr<ClientStatus> _status; - Timer::UP _reqTimer; - Timer::UP _cycleTimer; - Timer::UP _masterTimer; + std::unique_ptr<Timer> _reqTimer; + std::unique_ptr<Timer> _cycleTimer; + std::unique_ptr<Timer> _masterTimer; std::unique_ptr<HTTPClient> _http; std::unique_ptr<FileReader> _reader; std::unique_ptr<std::ofstream> _output; diff --git a/fbench/src/fbench/fbench.cpp b/fbench/src/fbench/fbench.cpp index c840797fc4e..c6a34099b3b 100644 --- a/fbench/src/fbench/fbench.cpp +++ b/fbench/src/fbench/fbench.cpp @@ -2,10 +2,10 @@ #include <util/timer.h> #include <httpclient/httpclient.h> #include <util/filereader.h> +#include <util/clientstatus.h> #include "client.h" #include "fbench.h" -#include <thread> - +#include <cstring> #include <cmath> sig_atomic_t exitSignal = 0; @@ -161,7 +161,7 @@ FBench::PrintSummary() if (_keepAlive) { printf("*** HTTP keep-alive statistics ***\n"); - printf("connection reuse count -- %" PRId64 "\n", status._reuseCnt); + printf("connection reuse count -- %zu\n", status._reuseCnt); } printf("***************** Benchmark Summary *****************\n"); printf("clients: %8ld\n", _clients.size()); diff --git a/fbench/src/httpclient/httpclient.cpp b/fbench/src/httpclient/httpclient.cpp index 56d8baa4264..c49ef5da12c 100644 --- a/fbench/src/httpclient/httpclient.cpp +++ b/fbench/src/httpclient/httpclient.cpp @@ -1,5 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "httpclient.h" +#include <cassert> +#include <cstring> #define FETCH_BUFLEN 5120 #define FIXED_REQ_MAX 256 diff --git a/fbench/src/test/clientstatus.cpp b/fbench/src/test/clientstatus.cpp index 751c578e4d3..c8b7bce1a34 100644 --- a/fbench/src/test/clientstatus.cpp +++ b/fbench/src/test/clientstatus.cpp @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <util/timer.h> -#include <util/filereader.h> -#include <httpclient/httpclient.h> +#include <util/clientstatus.h> #include <fbench/client.h> int diff --git a/fbench/src/test/httpclient.cpp b/fbench/src/test/httpclient.cpp index 31e3f8297c4..4201da68b97 100644 --- a/fbench/src/test/httpclient.cpp +++ b/fbench/src/test/httpclient.cpp @@ -49,6 +49,6 @@ main(int argc, char **argv) } else { printf("ERROR: could not fetch URL content.\n"); } - printf("REUSE COUNT: %" PRIu64 "\n", client->GetReuseCount()); + printf("REUSE COUNT: %zu\n", client->GetReuseCount()); return 0; } diff --git a/fbench/src/test/httpclient_splitstring.cpp b/fbench/src/test/httpclient_splitstring.cpp index 655738170bd..d766b0f8f4b 100644 --- a/fbench/src/test/httpclient_splitstring.cpp +++ b/fbench/src/test/httpclient_splitstring.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <httpclient/httpclient.h> +#include <cstring> class DebugHTTPClient : public HTTPClient { diff --git a/fnet/src/vespa/fnet/iocomponent.cpp b/fnet/src/vespa/fnet/iocomponent.cpp index 52c9cfd09b5..e5544ceff0e 100644 --- a/fnet/src/vespa/fnet/iocomponent.cpp +++ b/fnet/src/vespa/fnet/iocomponent.cpp @@ -2,7 +2,8 @@ #include "iocomponent.h" #include "transport_thread.h" - +#include <cassert> +#include <cstring> FNET_IOComponent::FNET_IOComponent(FNET_TransportThread *owner, int socket_fd, diff --git a/fnet/src/vespa/fnet/packetqueue.cpp b/fnet/src/vespa/fnet/packetqueue.cpp index df1938beb8e..b2ed08d4b04 100644 --- a/fnet/src/vespa/fnet/packetqueue.cpp +++ b/fnet/src/vespa/fnet/packetqueue.cpp @@ -3,6 +3,7 @@ #include "packetqueue.h" #include "packet.h" #include <vespa/fastos/time.h> +#include <cassert> void FNET_PacketQueue_NoLock::ExpandBuf(uint32_t needentries) diff --git a/logd/src/logd/watch.cpp b/logd/src/logd/watch.cpp index 0ff6510bd25..4a5e7df1474 100644 --- a/logd/src/logd/watch.cpp +++ b/logd/src/logd/watch.cpp @@ -9,9 +9,11 @@ #include "perform.h" #include "cmdbuf.h" #include <glob.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> LOG_SETUP(""); -LOG_RCSID("$Id$"); namespace logdemon { namespace { @@ -283,7 +285,7 @@ Watcher::watchfile() { removeOldLogs(filename); if (sb.st_size != offset) { - LOG(warning, "logfile rotation incomplete after %d s (dropping %" PRIu64 " bytes)", + LOG(warning, "logfile rotation incomplete after %d s (dropping %lu bytes)", rotTime, sb.st_size - offset); } else { LOG(debug, "logfile rotation complete after %d s", rotTime); @@ -412,7 +414,7 @@ Watcher::removeOldLogs(const char *prefix) if (totalsize > (_confsubscriber.getRemoveMegabytes() * 1048576LL)) { - LOG(info, "removing %s, total size (%" PRId64 ") too big", + LOG(info, "removing %s, total size (%ld) too big", fname, static_cast<int64_t>(totalsize)); if (unlink(fname) != 0) { LOG(warning, "cannot remove %s: %s", diff --git a/logd/src/tests/forward/forward.cpp b/logd/src/tests/forward/forward.cpp index 6a9a8668e9b..13e31cea464 100644 --- a/logd/src/tests/forward/forward.cpp +++ b/logd/src/tests/forward/forward.cpp @@ -3,6 +3,8 @@ #include <vespa/vespalib/testkit/testapp.h> #include <logd/forward.h> #include <sstream> +#include <fcntl.h> +#include <unistd.h> using ns_log::Logger; using namespace logdemon; diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp b/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp index 044bf1ea56e..5cbaef2363f 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp @@ -3,7 +3,7 @@ #include "environment.h" #include <vespa/vespalib/util/random.h> -#include <vespa/vespalib/util/vstringfmt.h> +#include <vespa/vespalib/util/stringfmt.h> #include <vespa/config/helper/configgetter.hpp> #include <vespa/config/subscription/configuri.h> #include <vespa/vespalib/stllike/asciistream.h> @@ -85,12 +85,12 @@ Environment::calculatePathInDir(const Types::BucketId& id, Directory& dir) vespalib::RandomGen randomizer(static_cast<uint32_t>(seed) ^ 0xba5eba11); for (uint32_t i = 1; i <= (uint32_t)_config->dirLevels; ++i) { - os << vespalib::make_vespa_string( + os << vespalib::make_string( "%.4x/", randomizer.nextUint32() % _config->dirSpread); } - os << vespalib::make_vespa_string("%.8" PRIx64 ".0", id.getId()); + os << vespalib::make_string("%.8" PRIx64 ".0", id.getId()); return os.str(); } diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp b/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp index 39530d4d8d1..5e1d835e3a2 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp @@ -10,6 +10,7 @@ #include <vespa/vespalib/util/guard.h> #include <vespa/vespalib/text/stringtokenizer.h> #include <fstream> +#include <sys/stat.h> #include <vespa/log/log.h> LOG_SETUP(".persistence.mountpointlist"); diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp index ee908fb6c6f..c4f4e7e8bc1 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp @@ -5,6 +5,7 @@ #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/exceptions.h> #include <sstream> +#include <cassert> #include <vespa/log/bufferedlogger.h> LOG_SETUP(".persistence.memfile.bufferedfilewriter"); diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h index 2370665f3d6..993004c01f0 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h @@ -16,16 +16,15 @@ #pragma once -#include <vespa/fastos/types.h> #include <vector> +#include <cstring> +#include <cstdint> namespace vespalib { class File; } -namespace storage { - -namespace memfile { +namespace storage::memfile { class BufferedFileWriter { public: @@ -115,6 +114,3 @@ private: }; } - -} - diff --git a/metrics/src/vespa/metrics/jsonwriter.cpp b/metrics/src/vespa/metrics/jsonwriter.cpp index d0b269a1521..8dd5e8fdbcb 100644 --- a/metrics/src/vespa/metrics/jsonwriter.cpp +++ b/metrics/src/vespa/metrics/jsonwriter.cpp @@ -1,13 +1,12 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/metrics/jsonwriter.h> +#include "jsonwriter.h" -#include <vespa/metrics/countmetric.h> -#include <vespa/metrics/valuemetric.h> -#include <vespa/metrics/metricsnapshot.h> -#include <vespa/vespalib/util/jsonstream.h> +#include "countmetric.h" +#include "valuemetric.h" +#include "metricsnapshot.h" -#include <algorithm> #include <iterator> +#include <cassert> namespace metrics { diff --git a/metrics/src/vespa/metrics/loadmetric.hpp b/metrics/src/vespa/metrics/loadmetric.hpp index 781a26a718d..0a66f985867 100644 --- a/metrics/src/vespa/metrics/loadmetric.hpp +++ b/metrics/src/vespa/metrics/loadmetric.hpp @@ -4,6 +4,7 @@ #include "loadmetric.h" #include "memoryconsumption.h" #include <vespa/vespalib/stllike/hash_map.hpp> +#include <cassert> namespace metrics { diff --git a/metrics/src/vespa/metrics/metric.cpp b/metrics/src/vespa/metrics/metric.cpp index 42096031486..5f39fccab07 100644 --- a/metrics/src/vespa/metrics/metric.cpp +++ b/metrics/src/vespa/metrics/metric.cpp @@ -10,6 +10,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/stringfmt.h> #include <iterator> +#include <cassert> namespace metrics { diff --git a/metrics/src/vespa/metrics/metric.h b/metrics/src/vespa/metrics/metric.h index 7819dc5f012..1b97dcb7d27 100644 --- a/metrics/src/vespa/metrics/metric.h +++ b/metrics/src/vespa/metrics/metric.h @@ -4,7 +4,6 @@ #include <vespa/vespalib/util/printable.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/regexp.h> -#include <assert.h> namespace metrics { diff --git a/metrics/src/vespa/metrics/metricset.cpp b/metrics/src/vespa/metrics/metricset.cpp index 0bc2f3363dc..af6d9c43d08 100644 --- a/metrics/src/vespa/metrics/metricset.cpp +++ b/metrics/src/vespa/metrics/metricset.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/stringfmt.h> #include <list> +#include <cassert> #include <vespa/log/log.h> LOG_SETUP(".metrics.metricsset"); @@ -74,6 +75,15 @@ MetricSet::getMetricInternal(const String& name) const return 0; } +int64_t MetricSet::getLongValue(const stringref &) const { + assert(false); + return 0; +} +double MetricSet::getDoubleValue(const stringref &) const { + assert(false); + return 0; +} + const Metric* MetricSet::getMetric(const String& name) const { diff --git a/metrics/src/vespa/metrics/metricset.h b/metrics/src/vespa/metrics/metricset.h index 5851cdea43c..e6f7cfc0deb 100644 --- a/metrics/src/vespa/metrics/metricset.h +++ b/metrics/src/vespa/metrics/metricset.h @@ -10,9 +10,7 @@ */ #pragma once -#include <map> -#include <vespa/metrics/metric.h> -#include <assert.h> +#include "metric.h" namespace metrics { @@ -65,10 +63,8 @@ public: void print(std::ostream&, bool verbose, const std::string& indent, uint64_t secondsPassed) const override; // These should never be called on metrics set. - int64_t getLongValue(const stringref & id) const override - { (void) id; assert(false); return 0; } - double getDoubleValue(const stringref & id) const override - { (void) id; assert(false); return 0; } + int64_t getLongValue(const stringref & id) const override; + double getDoubleValue(const stringref & id) const override; const Metric* getMetric(const String& name) const; Metric* getMetric(const String& name) { diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp index 78fbf6e57a2..0b6ad8f9acd 100644 --- a/metrics/src/vespa/metrics/metricsnapshot.cpp +++ b/metrics/src/vespa/metrics/metricsnapshot.cpp @@ -113,8 +113,8 @@ MetricSnapshotSet::timeForAnotherSnapshot(time_t currentTime) { if (currentTime >= lastTime + 2 * getPeriod()) { LOG(warning, "Metric snapshot set %s was asked if it was time for " "another snapshot, a whole period beyond when it " - "should have been done (Last update was at time %" - PRIu64 ", current time is %" PRIu64 " and period is %u). " + "should have been done (Last update was at time %lu" + ", current time is %lu and period is %u). " "Clearing data and updating time to current time.", getName().c_str(), lastTime, currentTime, getPeriod()); reset(currentTime); diff --git a/metrics/src/vespa/metrics/summetric.hpp b/metrics/src/vespa/metrics/summetric.hpp index 484d4f08169..01e4f5c5dfe 100644 --- a/metrics/src/vespa/metrics/summetric.hpp +++ b/metrics/src/vespa/metrics/summetric.hpp @@ -7,6 +7,7 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/stringfmt.h> #include <ostream> +#include <cassert> namespace metrics { diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h index 0e2821036ea..19076f053eb 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h @@ -15,6 +15,7 @@ #include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/stllike/hash_map.h> #include <atomic> +#include <map> namespace document { class FieldSet; diff --git a/persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp b/persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp index 19c1e8c7dd6..6f8600c7ca4 100644 --- a/persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp +++ b/persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp @@ -1,9 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "metricpersistenceprovider.h" +#include <cassert> #include <vespa/log/log.h> - LOG_SETUP(".persistence.spi.metrics"); #define PRE_PROCESS(opIndex) \ diff --git a/searchcore/src/apps/fdispatch/fdispatch.cpp b/searchcore/src/apps/fdispatch/fdispatch.cpp index cf70edb4875..21fa696330a 100644 --- a/searchcore/src/apps/fdispatch/fdispatch.cpp +++ b/searchcore/src/apps/fdispatch/fdispatch.cpp @@ -10,6 +10,7 @@ #include <vespa/vespalib/util/signalhandler.h> #include <vespa/fastos/app.h> #include <thread> +#include <getopt.h> #include <vespa/log/log.h> LOG_SETUP("fdispatch"); diff --git a/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp b/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp index 4422d659908..a0f34072f06 100644 --- a/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp +++ b/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp @@ -7,9 +7,10 @@ #include <vespa/fastlib/io/bufferedfile.h> #include <vespa/fastos/app.h> #include <iostream> -#include <algorithm> #include <sstream> #include <openssl/sha.h> +#include <cassert> +#include <getopt.h> #include <vespa/log/log.h> LOG_SETUP("vespa-gen-testdocs"); diff --git a/searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp b/searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp index 9d2cb958d39..aa6cbd40126 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp +++ b/searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp @@ -4,14 +4,14 @@ #include <vespa/searchcore/proton/reference/document_db_reference_registry.h> #include <vespa/searchcore/proton/test/mock_document_db_reference.h> #include <thread> +#include <unistd.h> + #include <vespa/log/log.h> LOG_SETUP("document_db_reference_registry_test"); -namespace proton -{ +namespace proton { -namespace -{ +namespace { std::mutex lock; diff --git a/searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp b/searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp index d9645e56606..248babad316 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp +++ b/searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "appcontext.h" +#include <cassert> FastS_TimeKeeper::FastS_TimeKeeper() : _clock(0.010), diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp index 402d6986aa8..1fcffa92cce 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp @@ -4,6 +4,7 @@ #include "attribute_directory.h" #include <vespa/vespalib/io/fileutil.h> #include <vespa/fastos/file.h> +#include <cassert> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp b/searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp index 1826b3a8d98..88aea2bd86c 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp @@ -1,9 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "docid_range_scheduler.h" +#include <cassert> -namespace proton { -namespace matching { +namespace proton::matching { namespace { @@ -160,5 +160,4 @@ AdaptiveDocidRangeScheduler::share_range(size_t thread_id, DocidRange todo) //----------------------------------------------------------------------------- -} // namespace proton::matching -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp index 2de1b5fd83f..fb7d712db9d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp @@ -3,7 +3,7 @@ #include "disk_mem_usage_sampler.h" #include <vespa/vespalib/util/timer.h> #include <vespa/searchlib/common/lambdatask.h> -#include <cstdlib> +#include <unistd.h> using search::makeLambdaTask; diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp index a833b063567..3750ba03f50 100644 --- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp @@ -20,6 +20,7 @@ #include <vespa/searchlib/common/idestructorcallback.h> #include <vespa/vespalib/util/closuretask.h> #include <vespa/vespalib/util/exceptions.h> +#include <unistd.h> #include <vespa/log/log.h> LOG_SETUP(".proton.server.feedhandler"); diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp index 8035925f9ec..47af497ec15 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp @@ -42,11 +42,8 @@ IndexFlushTarget::needUrgentFlush(void) const { bool urgent = _numFrozenMemoryIndexes > _maxFrozenMemoryIndexes; SerialNum flushedSerial = _indexMaintainer.getFlushedSerialNum(); - LOG(debug, - "Num frozen: %" PRIu32 " Urgent: %d, flushedSerial=%" PRIu64, - _numFrozenMemoryIndexes, - static_cast<int>(urgent), - flushedSerial); + LOG(debug, "Num frozen: %u Urgent: %d, flushedSerial=%lu", + _numFrozenMemoryIndexes, static_cast<int>(urgent), flushedSerial); return urgent; } diff --git a/searchlib/src/apps/docstore/benchmarkdatastore.cpp b/searchlib/src/apps/docstore/benchmarkdatastore.cpp index a1121769557..3dcfbbb31cc 100644 --- a/searchlib/src/apps/docstore/benchmarkdatastore.cpp +++ b/searchlib/src/apps/docstore/benchmarkdatastore.cpp @@ -8,6 +8,7 @@ #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/fastos/app.h> +#include <unistd.h> #include <vespa/log/log.h> LOG_SETUP("documentstore.benchmark"); diff --git a/searchlib/src/apps/uniform/uniform.cpp b/searchlib/src/apps/uniform/uniform.cpp index a42af9f1ff3..b69c2ddfc56 100644 --- a/searchlib/src/apps/uniform/uniform.cpp +++ b/searchlib/src/apps/uniform/uniform.cpp @@ -2,6 +2,7 @@ #include <vespa/fastos/app.h> #include <vespa/searchlib/bitcompression/compression.h> +#include <vespa/log/log.h> static uint64_t diff --git a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp index 4694eb55176..c2fcba379fd 100644 --- a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp +++ b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp @@ -9,13 +9,12 @@ #include <vespa/searchlib/diskindex/docidmapper.h> #include <vespa/searchlib/diskindex/wordnummapper.h> #include <vespa/searchlib/diskindex/fieldreader.h> -#include <vespa/searchlib/index/schemautil.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/queryeval/searchiterator.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> -#include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include <vespa/fastos/app.h> #include <iostream> +#include <getopt.h> #include <vespa/log/log.h> LOG_SETUP("vespa-index-inspect"); diff --git a/searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp b/searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp index a7b0e90ea1f..0cbd4bd9473 100644 --- a/searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp +++ b/searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp @@ -1,17 +1,16 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("foregroundtaskexecutor_test"); + #include <vespa/searchlib/common/foregroundtaskexecutor.h> #include <vespa/vespalib/testkit/testapp.h> #include <mutex> #include <condition_variable> +#include <unistd.h> -namespace search -{ +#include <vespa/log/log.h> +LOG_SETUP("foregroundtaskexecutor_test"); -namespace common -{ +namespace search::common { class Fixture @@ -117,7 +116,6 @@ TEST_F("require that task with different ids are serialized", Fixture) } -} // namespace common -} // namespace search +} TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp b/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp index 569bff0f6f3..7d158918715 100644 --- a/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp +++ b/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp @@ -1,18 +1,17 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("sequencedtaskexecutor_test"); + #include <vespa/searchlib/common/sequencedtaskexecutor.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/test/insertion_operators.h> #include <mutex> #include <condition_variable> +#include <unistd.h> -namespace search -{ +#include <vespa/log/log.h> +LOG_SETUP("sequencedtaskexecutor_test"); -namespace common -{ +namespace search::common { class Fixture @@ -236,7 +235,6 @@ TEST_F("require that executeLambda works", Fixture) } -} // namespace common -} // namespace search +} TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp index 820386f41ce..c926d1c2831 100644 --- a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp +++ b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp @@ -1010,8 +1010,8 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>) LOG(info, "Before feature compaction: allocElems=%" PRIu64 ", usedElems=%" PRIu64 ", deadElems=%" PRIu64 ", holdElems=%" PRIu64 - ", freeBuffers=%" PRIu32 ", activeBuffers=%" PRIu32 - ", holdBuffers=%" PRIu32, + ", freeBuffers=%u, activeBuffers=%u" + ", holdBuffers=%u", beforeStats._allocElems, beforeStats._usedElems, beforeStats._deadElems, @@ -1030,8 +1030,8 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>) LOG(info, "During feature compaction: allocElems=%" PRIu64 ", usedElems=%" PRIu64 ", deadElems=%" PRIu64 ", holdElems=%" PRIu64 - ", freeBuffers=%" PRIu32 ", activeBuffers=%" PRIu32 - ", holdBuffers=%" PRIu32, + ", freeBuffers=%u, activeBuffers=%u" + ", holdBuffers=%u", duringStats._allocElems, duringStats._usedElems, duringStats._deadElems, @@ -1045,8 +1045,8 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>) LOG(info, "After feature compaction: allocElems=%" PRIu64 ", usedElems=%" PRIu64 ", deadElems=%" PRIu64 ", holdElems=%" PRIu64 - ", freeBuffers=%" PRIu32 ", activeBuffers=%" PRIu32 - ", holdBuffers=%" PRIu32, + ", freeBuffers=%u, activeBuffers=%u" + ", holdBuffers=%u", afterStats._allocElems, afterStats._usedElems, afterStats._deadElems, @@ -1059,14 +1059,12 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>) TermFieldMatchDataArray matchData; matchData.add(&tfmd); { - PostingIterator itr(f._d.findFrozen("not", 0), featureStoreRef(f._d, 0), - 0, matchData); + PostingIterator itr(f._d.findFrozen("not", 0), featureStoreRef(f._d, 0), 0, matchData); itr.initFullRange(); EXPECT_TRUE(itr.isAtEnd()); } { - PostingIterator itr(f._d.findFrozen("a", 0), featureStoreRef(f._d, 0), - 0, matchData); + PostingIterator itr(f._d.findFrozen("a", 0), featureStoreRef(f._d, 0), 0, matchData); itr.initFullRange(); EXPECT_EQUAL(10u, itr.getDocId()); itr.unpack(10); @@ -1083,33 +1081,27 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>) EXPECT_TRUE(itr.isAtEnd()); } { - PostingIterator itr(f._d.findFrozen("x", 0), featureStoreRef(f._d, 0), - 0, matchData); + PostingIterator itr(f._d.findFrozen("x", 0), featureStoreRef(f._d, 0), 0, matchData); itr.initFullRange(); EXPECT_TRUE(itr.isAtEnd()); } { - PostingIterator itr(f._d.findFrozen("x", 1), featureStoreRef(f._d, 1), - 1, matchData); + PostingIterator itr(f._d.findFrozen("x", 1), featureStoreRef(f._d, 1), 1, matchData); itr.initFullRange(); EXPECT_EQUAL(30u, itr.getDocId()); itr.unpack(30); - EXPECT_EQUAL("{6:2[e=0,w=1,l=6]}", - toString(tfmd.getIterator(), true, true)); + EXPECT_EQUAL("{6:2[e=0,w=1,l=6]}", toString(tfmd.getIterator(), true, true)); } { - PostingIterator itr(f._d.findFrozen("x", 2), featureStoreRef(f._d, 2), - 2, matchData); + PostingIterator itr(f._d.findFrozen("x", 2), featureStoreRef(f._d, 2), 2, matchData); itr.initFullRange(); EXPECT_EQUAL(30u, itr.getDocId()); itr.unpack(30); // weight is hardcoded to 1 for new style il doc array field - EXPECT_EQUAL("{2:1[e=0,w=1,l=2]}", - toString(tfmd.getIterator(), true, true)); + EXPECT_EQUAL("{2:1[e=0,w=1,l=2]}", toString(tfmd.getIterator(), true, true)); } { - PostingIterator itr(f._d.findFrozen("x", 3), featureStoreRef(f._d, 3), - 3, matchData); + PostingIterator itr(f._d.findFrozen("x", 3), featureStoreRef(f._d, 3), 3, matchData); itr.initFullRange(); EXPECT_EQUAL(30u, itr.getDocId()); itr.unpack(30); diff --git a/searchlib/src/tests/postinglistbm/postinglistbm.cpp b/searchlib/src/tests/postinglistbm/postinglistbm.cpp index 58341a3458e..3a20af3e00a 100644 --- a/searchlib/src/tests/postinglistbm/postinglistbm.cpp +++ b/searchlib/src/tests/postinglistbm/postinglistbm.cpp @@ -13,6 +13,8 @@ #include <vespa/searchlib/index/docidandfeatures.h> #include <vespa/fastos/app.h> +#include <vespa/log/log.h> + using search::ResultSet; using search::fef::TermFieldMatchData; using search::fef::TermFieldMatchDataArray; diff --git a/searchlib/src/tests/sort/uca.cpp b/searchlib/src/tests/sort/uca.cpp index 3c55ac3dc31..579f3e7906e 100644 --- a/searchlib/src/tests/sort/uca.cpp +++ b/searchlib/src/tests/sort/uca.cpp @@ -1,17 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/common/sort.h> #include <vespa/searchlib/common/sortspec.h> -#include <vespa/searchlib/common/converters.h> #include <vespa/vespalib/util/array.h> -#include <memory> -#include <string> -#include <vector> -#include <stdexcept> #include <unicode/ustring.h> #include <unicode/coll.h> +#include <fcntl.h> +#include <unistd.h> +#include <vespa/log/log.h> LOG_SETUP("uca_stress"); using icu::Collator; diff --git a/searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp b/searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp index 33d0879220b..f6055376907 100644 --- a/searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp +++ b/searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp @@ -13,6 +13,7 @@ #include <string> #include <setjmp.h> #include <dlfcn.h> +#include <unistd.h> #include <vespa/log/log.h> LOG_SETUP("ioerrorhandler_test"); diff --git a/searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp b/searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp index c4c6b616567..c86a1c86dbb 100644 --- a/searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp +++ b/searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp @@ -1,16 +1,19 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("sigbushandler_test"); + #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/searchlib/util/statefile.h> #include <vespa/searchlib/util/sigbushandler.h> -#include <atomic> #include <iostream> #include <fstream> -#include <string> #include <vespa/searchlib/test/statefile.h> #include <vespa/searchlib/test/statestring.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/mman.h> + +#include <vespa/log/log.h> +LOG_SETUP("sigbushandler_test"); using namespace search::test::statefile; using namespace search::test::statestring; diff --git a/searchlib/src/tests/util/statefile/statefile_test.cpp b/searchlib/src/tests/util/statefile/statefile_test.cpp index 6480455ab3e..a9f087c773b 100644 --- a/searchlib/src/tests/util/statefile/statefile_test.cpp +++ b/searchlib/src/tests/util/statefile/statefile_test.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 <vespa/log/log.h> -LOG_SETUP("statefile_test"); + #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/searchlib/util/statefile.h> @@ -9,15 +8,18 @@ LOG_SETUP("statefile_test"); #include <fstream> #include <string> #include <vespa/searchlib/test/statefile.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <vespa/log/log.h> +LOG_SETUP("statefile_test"); using namespace search::test::statefile; -namespace search -{ +namespace search { -namespace -{ +namespace { bool hasFile(const char *name) diff --git a/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp b/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp index 8018c4f8010..4931455da8d 100644 --- a/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp +++ b/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "allocatedbitvector.h" +#include <cstring> namespace search { diff --git a/searchlib/src/vespa/searchlib/common/allocatedbitvector.h b/searchlib/src/vespa/searchlib/common/allocatedbitvector.h index bc9437f1b36..1f895eee93f 100644 --- a/searchlib/src/vespa/searchlib/common/allocatedbitvector.h +++ b/searchlib/src/vespa/searchlib/common/allocatedbitvector.h @@ -4,7 +4,7 @@ #pragma once -#include <vespa/searchlib/common/bitvector.h> +#include "bitvector.h" namespace search { diff --git a/searchlib/src/vespa/searchlib/common/partialbitvector.cpp b/searchlib/src/vespa/searchlib/common/partialbitvector.cpp index 462f78446b4..e57396c0dfa 100644 --- a/searchlib/src/vespa/searchlib/common/partialbitvector.cpp +++ b/searchlib/src/vespa/searchlib/common/partialbitvector.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "partialbitvector.h" +#include <cstring> namespace search { diff --git a/searchlib/src/vespa/searchlib/common/partialbitvector.h b/searchlib/src/vespa/searchlib/common/partialbitvector.h index d30f227304c..4cfd3e34383 100644 --- a/searchlib/src/vespa/searchlib/common/partialbitvector.h +++ b/searchlib/src/vespa/searchlib/common/partialbitvector.h @@ -4,7 +4,7 @@ #pragma once -#include <vespa/searchlib/common/bitvector.h> +#include "bitvector.h" namespace search { diff --git a/searchlib/src/vespa/searchlib/common/resultset.cpp b/searchlib/src/vespa/searchlib/common/resultset.cpp index 9a4627a56ab..69f3b13d709 100644 --- a/searchlib/src/vespa/searchlib/common/resultset.cpp +++ b/searchlib/src/vespa/searchlib/common/resultset.cpp @@ -4,6 +4,7 @@ #include "resultset.h" #include "bitvector.h" +#include <cstring> using vespalib::alloc::Alloc; diff --git a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp index d96f70e2cd3..0bc11dc30a6 100644 --- a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp @@ -3,6 +3,7 @@ #include "wordnummapper.h" #include <vespa/vespalib/objects/nbostream.h> #include <vespa/fastlib/io/bufferedfile.h> +#include <cassert> namespace search::diskindex { diff --git a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp index 23a4069d565..48207391eb1 100644 --- a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp +++ b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp @@ -4,8 +4,7 @@ #include "simple_index.h" #include <vespa/searchlib/common/rcuvector.hpp> -namespace search { -namespace predicate { +namespace search::predicate { namespace simpleindex { bool log_enabled(); @@ -219,7 +218,7 @@ void SimpleIndex<Posting, Key, DocId>::logVector( if (!simpleindex::log_enabled()) return; auto msg = vespalib::make_string( "%s vector for key '%016" PRIx64 "' with length %zu. Contains %zu documents " - "(doc id limit %" PRIu32", committed doc id limit %" PRIu32 ", ratio %f, " + "(doc id limit %u, committed doc id limit %u, ratio %f, " "vector count %zu)", action, key, vector_length, document_count, _limit_provider.getDocIdLimit(), _limit_provider.getCommittedDocIdLimit(), ratio, _vector_posting_lists.size()); @@ -312,5 +311,4 @@ MemoryUsage SimpleIndex<Posting, Key, DocId>::getMemoryUsage() const { return combined; }; -} // namespace predicate -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp index 0fd5d3d8acb..cfaf8108672 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp @@ -2,10 +2,8 @@ #include "fakeegcompr64filterocc.h" #include "fpfactory.h" -#include <vespa/searchlib/bitcompression/compression.h> -#include <vespa/searchlib/bitcompression/posocccompression.h> #include <vespa/searchlib/queryeval/iterators.h> -#include <vespa/searchlib/fef/termfieldmatchdataarray.h> +#include <vespa/vespalib/util/stringfmt.h> using search::fef::TermFieldMatchData; using search::fef::TermFieldMatchDataPosition; diff --git a/searchlib/src/vespa/searchlib/util/comprbuffer.cpp b/searchlib/src/vespa/searchlib/util/comprbuffer.cpp index 4f90d682988..8c7f97db022 100644 --- a/searchlib/src/vespa/searchlib/util/comprbuffer.cpp +++ b/searchlib/src/vespa/searchlib/util/comprbuffer.cpp @@ -3,6 +3,7 @@ #include "comprbuffer.h" #include <vespa/vespalib/objects/nbostream.h> #include <vespa/fastos/file.h> +#include <cassert> namespace search { diff --git a/searchlib/src/vespa/searchlib/util/dirtraverse.cpp b/searchlib/src/vespa/searchlib/util/dirtraverse.cpp index cb2dc39964b..57c7eee164f 100644 --- a/searchlib/src/vespa/searchlib/util/dirtraverse.cpp +++ b/searchlib/src/vespa/searchlib/util/dirtraverse.cpp @@ -5,6 +5,7 @@ #include "dirtraverse.h" #include <vespa/fastos/file.h> #include <cassert> +#include <cstring> namespace search { diff --git a/searchlib/src/vespa/searchlib/util/filealign.cpp b/searchlib/src/vespa/searchlib/util/filealign.cpp index 175287b1487..15bef611714 100644 --- a/searchlib/src/vespa/searchlib/util/filealign.cpp +++ b/searchlib/src/vespa/searchlib/util/filealign.cpp @@ -3,6 +3,7 @@ #include "filealign.h" #include <vespa/vespalib/objects/nbostream.h> #include <vespa/fastos/file.h> +#include <cassert> namespace search { diff --git a/searchlib/src/vespa/searchlib/util/fileutil.cpp b/searchlib/src/vespa/searchlib/util/fileutil.cpp index 2ac25b5ceb2..c1d34f66b0b 100644 --- a/searchlib/src/vespa/searchlib/util/fileutil.cpp +++ b/searchlib/src/vespa/searchlib/util/fileutil.cpp @@ -4,6 +4,9 @@ #include "filesizecalculator.h" #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/guard.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/stat.h> #include <vespa/log/log.h> LOG_SETUP(".searchlib.util.fileutil"); diff --git a/searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp b/searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp index d4de9202c4a..f044c2782b5 100644 --- a/searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp +++ b/searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp @@ -4,6 +4,7 @@ #include "statebuf.h" #include "statefile.h" #include <vespa/fastos/file.h> +#include <unistd.h> namespace search { diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.cpp b/searchlib/src/vespa/searchlib/util/rawbuf.cpp index 77fbd556b83..7a23614df73 100644 --- a/searchlib/src/vespa/searchlib/util/rawbuf.cpp +++ b/searchlib/src/vespa/searchlib/util/rawbuf.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/util/compress.h> #include <vespa/fastos/file.h> #include <cassert> +#include <cstring> namespace search { diff --git a/searchlib/src/vespa/searchlib/util/stringenum.cpp b/searchlib/src/vespa/searchlib/util/stringenum.cpp index 7e855c5b9f3..2a29754443a 100644 --- a/searchlib/src/vespa/searchlib/util/stringenum.cpp +++ b/searchlib/src/vespa/searchlib/util/stringenum.cpp @@ -4,6 +4,7 @@ #include "stringenum.h" #include <vespa/fastlib/io/bufferedfile.h> +#include <cassert> #include <vespa/log/log.h> LOG_SETUP(".seachlib.util.stringenum"); diff --git a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp index 09ef33413e0..e6f7bd21750 100644 --- a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp +++ b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/shutdownguard.h> +#include <unistd.h> +#include <sys/wait.h> using namespace vespalib; diff --git a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp index 3b09b672c57..c8a9590eb96 100644 --- a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp +++ b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp @@ -4,6 +4,9 @@ #include <vespa/vespalib/util/process_memory_stats.h> #include <iostream> #include <fstream> +#include <sys/mman.h> +#include <fcntl.h> +#include <unistd.h> using namespace vespalib; diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.cpp b/staging_vespalib/src/vespa/vespalib/util/clock.cpp index 1e474155ff4..403e1408747 100644 --- a/staging_vespalib/src/vespa/vespalib/util/clock.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/clock.cpp @@ -1,5 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #include "clock.h" +#include <cassert> using namespace fastos; diff --git a/staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp b/staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp index da608447d35..b8fd84f812e 100644 --- a/staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp @@ -1,5 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "shutdownguard.h" +#include <unistd.h> #include <vespa/log/log.h> LOG_SETUP(".vespalib.shutdownguard"); diff --git a/storage/src/tests/storageserver/documentapiconvertertest.cpp b/storage/src/tests/storageserver/documentapiconvertertest.cpp index d8761f9e84e..a0553625c8c 100644 --- a/storage/src/tests/storageserver/documentapiconvertertest.cpp +++ b/storage/src/tests/storageserver/documentapiconvertertest.cpp @@ -13,6 +13,7 @@ #include <vespa/document/bucket/bucketidfactory.h> #include <vespa/config/subscription/configuri.h> #include <vespa/vespalib/testkit/test_kit.h> +#include <climits> using document::DataType; using document::DocIdString; diff --git a/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp b/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp index 4512c6ddf4f..84b90ceedec 100644 --- a/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp +++ b/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp @@ -2,6 +2,7 @@ #include "bucketmanagermetrics.h" #include <vespa/vespalib/util/exceptions.h> +#include <cassert> namespace storage { diff --git a/storage/src/vespa/storage/distributor/operations/external/visitororder.h b/storage/src/vespa/storage/distributor/operations/external/visitororder.h index 88fd242a454..69aefb1ec33 100644 --- a/storage/src/vespa/storage/distributor/operations/external/visitororder.h +++ b/storage/src/vespa/storage/distributor/operations/external/visitororder.h @@ -1,8 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -namespace storage { +#include <climits> -namespace distributor { +namespace storage::distributor { struct VisitorOrder { const document::OrderingSpecification& _ordering; @@ -78,6 +78,4 @@ struct VisitorOrder { } -} - diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp index f17792302d1..536c9d764be 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp @@ -2,7 +2,7 @@ #include "joinoperation.h" #include <vespa/storageapi/message/bucketsplitting.h> - +#include <climits> #include <vespa/log/bufferedlogger.h> LOG_SETUP(".distributor.operation.idealstate.join"); diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp index 88f3a238a78..5c69c4576f0 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp @@ -4,9 +4,9 @@ #include <vespa/storage/distributor/idealstatemanager.h> #include <vespa/storage/common/bucketoperationlogger.h> #include <vespa/storageapi/message/bucketsplitting.h> +#include <climits> #include <vespa/log/bufferedlogger.h> - LOG_SETUP(".distributor.operation.idealstate.split"); using namespace storage::distributor; diff --git a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp index ac08e176a97..2039c1b5177 100644 --- a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp +++ b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp @@ -5,6 +5,7 @@ #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storage/common/bucketoperationlogger.h> #include <vespa/vespalib/util/xmlstream.hpp> +#include <climits> #include <vespa/log/log.h> LOG_SETUP(".pendingclusterstate"); diff --git a/storage/src/vespa/storage/persistence/bucketprocessor.cpp b/storage/src/vespa/storage/persistence/bucketprocessor.cpp index fd9b51a90c7..c512cdd461a 100644 --- a/storage/src/vespa/storage/persistence/bucketprocessor.cpp +++ b/storage/src/vespa/storage/persistence/bucketprocessor.cpp @@ -3,6 +3,7 @@ #include "bucketprocessor.h" #include <vespa/document/fieldset/fieldsets.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <cassert> namespace storage { diff --git a/storage/src/vespa/storage/persistence/splitbitdetector.cpp b/storage/src/vespa/storage/persistence/splitbitdetector.cpp index d8bf01775c8..1133c470bb0 100644 --- a/storage/src/vespa/storage/persistence/splitbitdetector.cpp +++ b/storage/src/vespa/storage/persistence/splitbitdetector.cpp @@ -5,6 +5,7 @@ #include <vespa/document/bucket/bucketidfactory.h> #include <vespa/document/base/documentid.h> #include <sstream> +#include <cassert> #include <vespa/log/bufferedlogger.h> LOG_SETUP(".persistence.split.bitdetector"); diff --git a/storage/src/vespa/storage/storageserver/distributornode.h b/storage/src/vespa/storage/storageserver/distributornode.h index 47b14470639..34f2dbb42a7 100644 --- a/storage/src/vespa/storage/storageserver/distributornode.h +++ b/storage/src/vespa/storage/storageserver/distributornode.h @@ -24,7 +24,7 @@ class DistributorNode uint64_t _lastUniqueTimestampRequested; uint32_t _uniqueTimestampCounter; bool _manageActiveBucketCopies; - StorageLink::UP _retrievedCommunicationManager; + std::unique_ptr<StorageLink> _retrievedCommunicationManager; public: typedef std::unique_ptr<DistributorNode> UP; @@ -38,7 +38,7 @@ public: DistributorNodeContext&, ApplicationGenerationFetcher& generationFetcher, NeedActiveState, - StorageLink::UP communicationManager = StorageLink::UP()); + std::unique_ptr<StorageLink> communicationManager); ~DistributorNode(); const lib::NodeType& getNodeType() const override { return lib::NodeType::DISTRIBUTOR; } @@ -49,7 +49,7 @@ public: private: void initializeNodeSpecific() override; - StorageLink::UP createChain() override; + std::unique_ptr<StorageLink> createChain() override; api::Timestamp getUniqueTimestamp() override; /** diff --git a/storage/src/vespa/storage/storageserver/servicelayernode.h b/storage/src/vespa/storage/storageserver/servicelayernode.h index 4e0de3bbf24..848cc1d1475 100644 --- a/storage/src/vespa/storage/storageserver/servicelayernode.h +++ b/storage/src/vespa/storage/storageserver/servicelayernode.h @@ -11,6 +11,8 @@ #include "applicationgenerationfetcher.h" #include "servicelayernodecontext.h" #include "storagenode.h" +#include <vespa/storage/visiting/visitormessagesessionfactory.h> +#include <vespa/storage/common/visitorfactory.h> #include <vespa/storage/bucketdb/minimumusedbitstracker.h> #include <vespa/persistence/spi/persistenceprovider.h> #include <vespa/config-stor-devices.h> @@ -65,7 +67,7 @@ private: void configure(std::unique_ptr<vespa::config::storage::StorDevicesConfig> config) override; VisitorMessageSession::UP createSession(Visitor&, VisitorThread&) override; documentapi::Priority::Value toDocumentPriority(uint8_t storagePriority) const override; - StorageLink::UP createChain() override; + std::unique_ptr<StorageLink> createChain() override; void removeConfigSubscriptions() override; }; diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp index ac386674032..27f98b478ce 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.cpp +++ b/storage/src/vespa/storage/storageserver/storagenode.cpp @@ -1,37 +1,22 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "storagenode.h" -#include "bouncer.h" -#include "bucketintegritychecker.h" #include "communicationmanager.h" -#include "mergethrottler.h" -#include "opslogger.h" #include "statemanager.h" #include "statereporter.h" #include "storagemetricsset.h" +#include "storagenodecontext.h" -#include <vespa/storage/bucketdb/bucketmanager.h> -#include <vespa/storage/bucketdb/storagebucketdbinitializer.h> -#include <vespa/storage/bucketmover/bucketmover.h> -#include <vespa/storageframework/storageframework.h> -#include <vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.h> +#include <vespa/storage/frameworkimpl/memory/memorystatusviewer.h> +#include <vespa/storage/frameworkimpl/status/statuswebserver.h> +#include <vespa/storage/frameworkimpl/thread/deadlockdetector.h> #include <vespa/storage/common/statusmetricconsumer.h> -#include <vespa/storage/common/hostreporter/hostinfo.h> -#include <vespa/storage/distributor/bucketdbupdater.h> -#include <vespa/storage/distributor/distributor.h> -#include <vespa/storage/distributor/pendingmessagetracker.h> -#include <vespa/storage/persistence/filestorage/filestormanager.h> -#include <vespa/storage/storageutil/functor.h> -#include <vespa/storage/storageutil/log.h> -#include <vespa/storage/visiting/visitormanager.h> -#include <vespa/storage/visiting/messagebusvisitormessagesession.h> -#include <vespa/vdslib/distribution/distribution.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/metrics/metricmanager.h> -#include <fstream> -#include <sstream> +#include <fcntl.h> +#include <vespa/log/log.h> LOG_SETUP(".node.server"); namespace storage { diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h index 530920b7578..4c4918e6977 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.h +++ b/storage/src/vespa/storage/storageserver/storagenode.h @@ -12,35 +12,23 @@ #pragma once -#include "storagemetricsset.h" -#include "storagenodecontext.h" -#include "applicationgenerationfetcher.h" -#include <vespa/document/bucket/bucketidfactory.h> -#include <vespa/storage/config/config-stor-server.h> - -#include <vespa/config/helper/legacysubscriber.h> -#include <vespa/document/bucket/bucketid.h> -#include <vespa/document/config/config-documenttypes.h> -#include <vespa/documentapi/loadtypes/loadtypeset.h> -#include <vespa/metrics/metrics.h> -#include <vespa/storage/bucketdb/storbucketdb.h> +#include <vespa/storage/storageutil/resumeguard.h> #include <vespa/storage/common/doneinitializehandler.h> -#include <vespa/storage/common/storagelink.h> -#include <vespa/storage/common/visitorfactory.h> -#include <vespa/storage/config/config-stor-prioritymapping.h> -#include <vespa/storageframework/defaultimplementation/clock/realclock.h> -#include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> -#include <vespa/storage/frameworkimpl/status/statuswebserver.h> -#include <vespa/storage/frameworkimpl/thread/deadlockdetector.h> -#include <vespa/storageframework/defaultimplementation/memory/memorymanager.h> -#include <vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h> -#include <vespa/storage/frameworkimpl/memory/memorystatusviewer.h> #include <vespa/storageframework/generic/metric/metricupdatehook.h> -#include <vespa/storage/visiting/visitormessagesessionfactory.h> -#include <vespa/storage/storageutil/resumeguard.h> +#include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> + +#include <vespa/config/subscription/configuri.h> +#include <vespa/config/helper/ifetchercallback.h> +#include <vespa/config/helper/configfetcher.h> + +#include <vespa/storage/config/config-stor-prioritymapping.h> +#include <vespa/storage/config/config-stor-server.h> +#include <vespa/document/config/config-documenttypes.h> #include <vespa/config-upgrading.h> #include <vespa/config-stor-distribution.h> +namespace document { class DocumentTypeRepo; } + namespace storage { class StatusMetricConsumer; @@ -49,6 +37,17 @@ class CommunicationManager; class FileStorManager; class HostInfo; class StateManager; +class MemoryStatusViewer; +class StatusWebServer; +class StorageLink; +class DeadLockDetector; +class StorageMetricSet; +class StorageNodeContext; +class ApplicationGenerationFetcher; +class StorageComponent; + +namespace lib { class NodeType; } + class StorageNode : private config::IFetcherCallback<vespa::config::content::core::StorServerConfig>, private config::IFetcherCallback<vespa::config::content::StorDistributionConfig>, @@ -82,7 +81,7 @@ public: void updateMetrics(const MetricLockGuard & guard) override; /** Updates the document type repo. */ - void setNewDocumentRepo(const document::DocumentTypeRepo::SP& repo); + void setNewDocumentRepo(const std::shared_ptr<document::DocumentTypeRepo>& repo); /** * Pauses the persistence processing. While the returned ResumeGuard @@ -154,7 +153,7 @@ protected: std::unique_ptr<vespa::config::content::StorDistributionConfig> _newDistributionConfig; std::unique_ptr<vespa::config::content::core::StorPrioritymappingConfig> _newPriorityConfig; std::unique_ptr<document::DocumenttypesConfig> _newDoctypesConfig; - StorageComponent::UP _component; + std::unique_ptr<StorageComponent> _component; config::ConfigUri _configUri; CommunicationManager* _communicationManager; @@ -170,7 +169,7 @@ protected: void initialize(); virtual void subscribeToConfigs(); virtual void initializeNodeSpecific() = 0; - virtual StorageLink::UP createChain() = 0; + virtual std::unique_ptr<StorageLink> createChain() = 0; virtual void handleLiveConfigUpdate(); void shutdown(); virtual void removeConfigSubscriptions(); diff --git a/storage/src/vespa/storage/storageutil/resumeguard.h b/storage/src/vespa/storage/storageutil/resumeguard.h index f6003000205..a6fdcbbe506 100644 --- a/storage/src/vespa/storage/storageutil/resumeguard.h +++ b/storage/src/vespa/storage/storageutil/resumeguard.h @@ -13,7 +13,7 @@ public: }; ResumeGuard() - : _cb(NULL) + : _cb(nullptr) {} ResumeGuard(Callback& cb) @@ -21,7 +21,7 @@ public: ResumeGuard(const ResumeGuard& other) { _cb = other._cb; - const_cast<ResumeGuard&>(other)._cb = NULL; + const_cast<ResumeGuard&>(other)._cb = nullptr; } ~ResumeGuard() { diff --git a/storage/src/vespa/storage/tools/throttlingsim.cpp b/storage/src/vespa/storage/tools/throttlingsim.cpp index 26fa4f94875..cd3c0c1cea4 100644 --- a/storage/src/vespa/storage/tools/throttlingsim.cpp +++ b/storage/src/vespa/storage/tools/throttlingsim.cpp @@ -3,6 +3,7 @@ #include "throttlingsim.h" #include <algorithm> #include <vespa/vespalib/util/stringfmt.h> +#include <unistd.h> bool Receiver::enqueue(const Message& msg) { vespalib::MonitorGuard lock(sync); diff --git a/storage/src/vespa/storage/visiting/visitormessagesessionfactory.h b/storage/src/vespa/storage/visiting/visitormessagesessionfactory.h index fb090fc2860..5515595a1c5 100644 --- a/storage/src/vespa/storage/visiting/visitormessagesessionfactory.h +++ b/storage/src/vespa/storage/visiting/visitormessagesessionfactory.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/storage/visiting/visitormessagesession.h> +#include "visitormessagesession.h" namespace storage { diff --git a/storageapi/src/vespa/storageapi/message/visitor.cpp b/storageapi/src/vespa/storageapi/message/visitor.cpp index 8da8f208f3d..851896f4d55 100644 --- a/storageapi/src/vespa/storageapi/message/visitor.cpp +++ b/storageapi/src/vespa/storageapi/message/visitor.cpp @@ -2,9 +2,9 @@ #include "visitor.h" #include <vespa/vespalib/util/array.hpp> +#include <climits> -namespace storage { -namespace api { +namespace storage::api { IMPLEMENT_COMMAND(CreateVisitorCommand, CreateVisitorReply) IMPLEMENT_REPLY(CreateVisitorReply) @@ -230,5 +230,4 @@ operator<<(std::ostream& out, const VisitorInfoCommand::BucketTimestampPair& pai return out << pair.bucketId << " - " << pair.timestamp; } -} // api -} // storage +} diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h b/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h index 87659b55250..7319a1e7d57 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h +++ b/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h @@ -31,9 +31,8 @@ namespace metrics { } -namespace storage { -namespace framework { -namespace defaultimplementation { + +namespace storage::framework::defaultimplementation { struct ShutdownListener { virtual ~ShutdownListener() {} @@ -89,8 +88,4 @@ public: }; -} // defaultimplementation -} // framework -} // storage - - +} diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp index 54da9be7e31..2351edd267c 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp +++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp @@ -84,8 +84,8 @@ MemoryState::addToEntry(const MemoryAllocationType& type, uint64_t memory, AllocationResult result, bool forcedAllocation, uint64_t allocationCounts) { - LOG(spam, "Allocating memory %s - %" PRIu64 " bytes at priority %u. " - "Count %" PRIu64 ".", + LOG(spam, "Allocating memory %s - %lu bytes at priority %u. " + "Count %lu.", type.getName().c_str(), memory, priority, allocationCounts); PriorityMap& map(_current._allocations[&type]); Entry& e(map[priority]); @@ -110,7 +110,7 @@ MemoryState::addToEntry(const MemoryAllocationType& type, uint64_t memory, if (_current._usedWithoutCache > _max._usedWithoutCache + _minJumpToUpdateMax) { - LOG(spam, "Updating max to current %" PRIu64 " bytes of memory used", + LOG(spam, "Updating max to current %lu bytes of memory used", _current._usedWithoutCache); _max = _current; _max._timeTaken = _clock->getTimeInSeconds(); @@ -122,8 +122,8 @@ MemoryState::removeFromEntry(const MemoryAllocationType& type, uint64_t memory, uint8_t priority, uint64_t allocationCounts) { - LOG(spam, "Freeing memory %s - %" PRIu64 " bytes at priority %u. " - "Count %" PRIu64 ".", + LOG(spam, "Freeing memory %s - %lu bytes at priority %u. " + "Count %lu.", type.getName().c_str(), memory, priority, allocationCounts); PriorityMap& map(_current._allocations[&type]); Entry& e(map[priority]); diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp index 681ee10df0f..51bb7ba5019 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp +++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp @@ -5,14 +5,12 @@ #include <vespa/log/log.h> LOG_SETUP(".memory.logic.priority"); -namespace storage { -namespace framework { -namespace defaultimplementation { +namespace storage::framework::defaultimplementation { PriorityMemoryLogic::PriorityMemoryLogic(Clock& c, uint64_t maxMem) : SimpleMemoryLogic(c, maxMem) { - LOG(debug, "Setup priority memory logic with max memory of %" PRIu64 " bytes", maxMem); + LOG(debug, "Setup priority memory logic with max memory of %lu bytes", maxMem); } float @@ -29,6 +27,4 @@ PriorityMemoryLogic::print(std::ostream& out, bool verbose, SimpleMemoryLogic::print(out, verbose, indent); } -} // defaultimplementation -} // framework -} // storage +} diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp index 1fb4adc6618..b9ccb2d4d9f 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp +++ b/storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp @@ -82,9 +82,9 @@ ThreadImpl::registerTick(CycleType cycleType, MilliSecTime time) if (data._lastTickMs == 0) { return; } if (previousTickMs > nowMs) { - LOGBP(warning, "Thread is registering tick at time %" PRIu64 ", but " - "last time it registered a tick, the time was %" - PRIu64 ". Assuming clock has been adjusted backwards", + LOGBP(warning, "Thread is registering tick at time %lu, but " + "last time it registered a tick, the time was %lu" + ". Assuming clock has been adjusted backwards", nowMs, previousTickMs); return; } diff --git a/storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h b/storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h index 7d0ae594e5f..7b05bbe8040 100644 --- a/storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h +++ b/storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h @@ -10,22 +10,24 @@ */ #pragma once -#include <vespa/vespalib/stllike/string.h> +#include <vespa/storageframework/generic/clock/time.h> #include <vespa/vespalib/util/sync.h> -namespace storage { -namespace framework { +namespace metrics { + class Metric; +} + +namespace storage::framework { + +class MetricUpdateHook; struct MetricRegistrator { virtual ~MetricRegistrator() {} virtual void registerMetric(metrics::Metric&) = 0; - virtual void registerUpdateHook(vespalib::stringref name, - MetricUpdateHook& hook, - SecondTime period) = 0; + virtual void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, SecondTime period) = 0; virtual vespalib::MonitorGuard getMetricManagerLock() = 0; }; -} // framework -} // storage +} diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp index 05b61944a33..6ef391fa56a 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/storageserver/app/distributorprocess.h> +#include "distributorprocess.h" +#include <vespa/storage/common/storagelink.h> #include <vespa/config/helper/configgetter.hpp> #include <vespa/log/log.h> @@ -49,12 +50,10 @@ DistributorProcess::updateConfig() { Process::updateConfig(); if (_distributorConfigHandler->isChanged()) { - _node->handleConfigChange( - *_distributorConfigHandler->getConfig()); + _node->handleConfigChange(*_distributorConfigHandler->getConfig()); } if (_visitDispatcherConfigHandler->isChanged()) { - _node->handleConfigChange( - *_visitDispatcherConfigHandler->getConfig()); + _node->handleConfigChange(*_visitDispatcherConfigHandler->getConfig()); } } @@ -76,11 +75,9 @@ DistributorProcess::configUpdated() void DistributorProcess::createNode() { - _node.reset(new DistributorNode(_configUri, _context, *this, _activeFlag)); - _node->handleConfigChange( - *_distributorConfigHandler->getConfig()); - _node->handleConfigChange( - *_visitDispatcherConfigHandler->getConfig()); + _node.reset(new DistributorNode(_configUri, _context, *this, _activeFlag, StorageLink::UP())); + _node->handleConfigChange(*_distributorConfigHandler->getConfig()); + _node->handleConfigChange(*_visitDispatcherConfigHandler->getConfig()); } } // storage diff --git a/storageserver/src/vespa/storageserver/app/process.cpp b/storageserver/src/vespa/storageserver/app/process.cpp index ea8ae4da485..a604490ba85 100644 --- a/storageserver/src/vespa/storageserver/app/process.cpp +++ b/storageserver/src/vespa/storageserver/app/process.cpp @@ -2,6 +2,7 @@ #include "process.h" #include <vespa/storage/storageserver/storagenode.h> +#include <vespa/storage/storageserver/storagenodecontext.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/log/log.h> @@ -19,11 +20,9 @@ Process::setupConfig(uint64_t subscribeTimeout) { _documentHandler = _configSubscriber.subscribe<document::DocumenttypesConfig>(_configUri.getConfigId(), subscribeTimeout); if (!_configSubscriber.nextConfig()) { - throw vespalib::TimeoutException( - "Could not subscribe to document config within timeout"); + throw vespalib::TimeoutException("Could not subscribe to document config within timeout"); } - _repos.push_back(document::DocumentTypeRepo::SP( - new document::DocumentTypeRepo(*_documentHandler->getConfig()))); + _repos.push_back(std::make_shared<document::DocumentTypeRepo>(*_documentHandler->getConfig())); getContext().getComponentRegister().setDocumentTypeRepo(_repos.back()); } @@ -42,9 +41,7 @@ void Process::updateConfig() { if (_documentHandler->isChanged()) { - _repos.push_back(document::DocumentTypeRepo::SP( - new document::DocumentTypeRepo( - *_documentHandler->getConfig()))); + _repos.push_back(std::make_shared<document::DocumentTypeRepo>(*_documentHandler->getConfig())); getNode().setNewDocumentRepo(_repos.back()); } } diff --git a/vdslib/src/tests/container/documentlisttest.cpp b/vdslib/src/tests/container/documentlisttest.cpp index 17fc613c8ab..884241cc483 100644 --- a/vdslib/src/tests/container/documentlisttest.cpp +++ b/vdslib/src/tests/container/documentlisttest.cpp @@ -9,6 +9,8 @@ #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/testkit/testapp.h> #include <cppunit/extensions/HelperMacros.h> +#include <fcntl.h> +#include <unistd.h> using document::DocumentTypeRepo; using document::readDocumenttypesConfig; diff --git a/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp b/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp index bc640370799..7406e17430d 100644 --- a/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp +++ b/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp @@ -5,6 +5,8 @@ #include <algorithm> #include <dirent.h> #include <unistd.h> +#include <cstring> +#include <sys/stat.h> #include "application.h" diff --git a/vespalib/src/tests/guard/guard_test.cpp b/vespalib/src/tests/guard/guard_test.cpp index 358a56d44cb..a9d5d5f894c 100644 --- a/vespalib/src/tests/guard/guard_test.cpp +++ b/vespalib/src/tests/guard/guard_test.cpp @@ -1,8 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/guard.h> +#include <fcntl.h> +#include <unistd.h> using namespace vespalib; diff --git a/vespalib/src/tests/net/selector/selector_test.cpp b/vespalib/src/tests/net/selector/selector_test.cpp index c91b3e0b054..964e37adf3b 100644 --- a/vespalib/src/tests/net/selector/selector_test.cpp +++ b/vespalib/src/tests/net/selector/selector_test.cpp @@ -6,6 +6,7 @@ #include <thread> #include <functional> #include <chrono> +#include <fcntl.h> using namespace vespalib; diff --git a/vespalib/src/tests/net/socket/socket_test.cpp b/vespalib/src/tests/net/socket/socket_test.cpp index bfeb73f72fc..c7cb2a0b6d9 100644 --- a/vespalib/src/tests/net/socket/socket_test.cpp +++ b/vespalib/src/tests/net/socket/socket_test.cpp @@ -10,6 +10,8 @@ #include <thread> #include <functional> #include <chrono> +#include <unistd.h> +#include <sys/stat.h> using namespace vespalib; diff --git a/vespalib/src/tests/signalhandler/signalhandler_test.cpp b/vespalib/src/tests/signalhandler/signalhandler_test.cpp index a83661e8697..b11cc5746d9 100644 --- a/vespalib/src/tests/signalhandler/signalhandler_test.cpp +++ b/vespalib/src/tests/signalhandler/signalhandler_test.cpp @@ -1,8 +1,11 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("signalhandler_test"); + #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/signalhandler.h> +#include <unistd.h> + +#include <vespa/log/log.h> +LOG_SETUP("signalhandler_test"); using namespace vespalib; diff --git a/vespalib/src/tests/text/utf8/utf8_test.cpp b/vespalib/src/tests/text/utf8/utf8_test.cpp index 9110b44f646..a44c0a7560b 100644 --- a/vespalib/src/tests/text/utf8/utf8_test.cpp +++ b/vespalib/src/tests/text/utf8/utf8_test.cpp @@ -1,10 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("utf8_test"); + #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/text/utf8.h> +#include <fcntl.h> +#include <unistd.h> + +#include <vespa/log/log.h> +LOG_SETUP("utf8_test"); #if 0 #include <vespa/fastlib/text/unicodeutil.h> #endif diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp b/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp index f8df7cb5221..ee25652a3a8 100644 --- a/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp +++ b/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp @@ -3,12 +3,9 @@ #pragma once #include <vespa/fastos/dynamiclibrary.h> +#include <cstring> -namespace vespalib { - -namespace hwaccelrated { - -namespace avx { +namespace vespalib::hwaccelrated::avx { namespace { @@ -80,5 +77,3 @@ T dotProductSelectAlignment(const T * af, const T * bf, size_t sz) } } -} -} diff --git a/vespalib/src/vespa/vespalib/io/fileutil.cpp b/vespalib/src/vespa/vespalib/io/fileutil.cpp index 3b092bd63f4..389218cea35 100644 --- a/vespalib/src/vespa/vespalib/io/fileutil.cpp +++ b/vespalib/src/vespa/vespalib/io/fileutil.cpp @@ -6,6 +6,9 @@ #include <vespa/vespalib/util/stringfmt.h> #include <vespa/fastos/file.h> #include <ostream> +#include <cassert> +#include <unistd.h> +#include <fcntl.h> #include <sys/stat.h> #include <vespa/log/log.h> diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp index 8d3ff1d77dc..7b895f3eb73 100644 --- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp +++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp @@ -9,6 +9,7 @@ #include <algorithm> #include <limits> #include <stdexcept> +#include <cassert> namespace vespalib { diff --git a/vespalib/src/vespa/vespalib/test/socket_options_verifier.h b/vespalib/src/vespa/vespalib/test/socket_options_verifier.h index ace0adb9c8e..2be96b861af 100644 --- a/vespalib/src/vespa/vespalib/test/socket_options_verifier.h +++ b/vespalib/src/vespa/vespalib/test/socket_options_verifier.h @@ -3,6 +3,9 @@ #pragma once #include <vespa/vespalib/testkit/test_kit.h> +#include <fcntl.h> +#include <unistd.h> +#include <netinet/tcp.h> namespace vespalib { namespace test { diff --git a/vespalib/src/vespa/vespalib/testkit/test_kit.h b/vespalib/src/vespa/vespalib/testkit/test_kit.h index d9f8428c680..7e6b07d71df 100644 --- a/vespalib/src/vespa/vespalib/testkit/test_kit.h +++ b/vespalib/src/vespa/vespalib/testkit/test_kit.h @@ -3,6 +3,7 @@ #pragma once #include <memory> +#include <cstring> #include "test_macros.h" #include "test_comparators.h" #include "test_master.h" diff --git a/vespalib/src/vespa/vespalib/testkit/test_master.cpp b/vespalib/src/vespa/vespalib/testkit/test_master.cpp index 9ea5a8a1c6a..d5309845dfd 100644 --- a/vespalib/src/vespa/vespalib/testkit/test_master.cpp +++ b/vespalib/src/vespa/vespalib/testkit/test_master.cpp @@ -2,6 +2,7 @@ #include "test_master.h" #include <vespa/vespalib/util/barrier.h> +#include <cstring> namespace vespalib { diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index be443163b81..dff744a0a41 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -9,6 +9,7 @@ #include <atomic> #include <unordered_map> #include <vespa/fastos/file.h> +#include <unistd.h> #include <vespa/log/log.h> LOG_SETUP(".vespalib.alloc"); diff --git a/vespalib/src/vespa/vespalib/util/slaveproc.cpp b/vespalib/src/vespa/vespalib/util/slaveproc.cpp index 76fa86ac5db..8b35fa3559b 100644 --- a/vespalib/src/vespa/vespalib/util/slaveproc.cpp +++ b/vespalib/src/vespa/vespalib/util/slaveproc.cpp @@ -3,6 +3,7 @@ #include <vespa/fastos/time.h> #include "guard.h" #include "slaveproc.h" +#include <cstring> #ifndef FASTOS_NO_THREADS diff --git a/vespalib/src/vespa/vespalib/util/stringfmt.h b/vespalib/src/vespa/vespalib/util/stringfmt.h index 625c9530a48..f806368adf5 100644 --- a/vespalib/src/vespa/vespalib/util/stringfmt.h +++ b/vespalib/src/vespa/vespalib/util/stringfmt.h @@ -7,6 +7,7 @@ #ifndef PRId64 #define PRId64 "ld" #define PRIu64 "lu" + #define PRIx64 "lx" #endif namespace vespalib { diff --git a/vespalib/src/vespa/vespalib/util/sync.h b/vespalib/src/vespa/vespalib/util/sync.h index 737cdbc3fed..ccadbfb8dfc 100644 --- a/vespalib/src/vespa/vespalib/util/sync.h +++ b/vespalib/src/vespa/vespalib/util/sync.h @@ -6,6 +6,8 @@ #include <vespa/fastos/mutex.h> #include <vespa/fastos/cond.h> #include <vespa/fastos/time.h> +#include <cassert> + namespace vespalib { diff --git a/vespalog/src/test/threads/testthreads.cpp b/vespalog/src/test/threads/testthreads.cpp index b6fea71cb6c..dc469018a5f 100644 --- a/vespalog/src/test/threads/testthreads.cpp +++ b/vespalog/src/test/threads/testthreads.cpp @@ -4,6 +4,9 @@ #include <vespa/fastos/thread.h> #include <vespa/log/bufferedlogger.h> #include <iostream> +#include <fcntl.h> +#include <unistd.h> +#include <sys/stat.h> using std::string; diff --git a/vespalog/src/vespa/log/log.cpp b/vespalog/src/vespa/log/log.cpp index c44d490229b..eb100fd6631 100644 --- a/vespalog/src/vespa/log/log.cpp +++ b/vespalog/src/vespa/log/log.cpp @@ -13,6 +13,9 @@ LOG_SETUP_INDIRECT(".log", "$Id$"); #include "bufferedlogger.h" #include <vespa/fastos/thread.h> +#include <cassert> +#include <cstdarg> +#include <unistd.h> namespace ns_log { diff --git a/vespalog/src/vespa/log/log.h b/vespalog/src/vespa/log/log.h index b78fcf4a72d..127baf14d55 100644 --- a/vespalog/src/vespa/log/log.h +++ b/vespalog/src/vespa/log/log.h @@ -300,3 +300,9 @@ extern void log_abort(const char *message, #else #define LOG_ASSERT(expr) #endif // #ifndef NDEBUG + +#ifndef PRId64 + #define PRId64 "ld" + #define PRIu64 "lu" + #define PRIx64 "lx" +#endif diff --git a/vespamalloc/src/tests/doubledelete/expectsignal.cpp b/vespamalloc/src/tests/doubledelete/expectsignal.cpp index e65f0d67615..9ac93da014d 100644 --- a/vespamalloc/src/tests/doubledelete/expectsignal.cpp +++ b/vespamalloc/src/tests/doubledelete/expectsignal.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/slaveproc.h> +#include <sys/wait.h> using namespace vespalib; diff --git a/vespamalloc/src/tests/overwrite/expectsignal.cpp b/vespamalloc/src/tests/overwrite/expectsignal.cpp index ec1ce893d2e..e78f1b7b181 100644 --- a/vespamalloc/src/tests/overwrite/expectsignal.cpp +++ b/vespamalloc/src/tests/overwrite/expectsignal.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/slaveproc.h> +#include <sys/wait.h> using namespace vespalib; diff --git a/vespamalloc/src/tests/test.cpp b/vespamalloc/src/tests/test.cpp index 6499eaca7ea..899c37d0c0e 100644 --- a/vespamalloc/src/tests/test.cpp +++ b/vespamalloc/src/tests/test.cpp @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/thread.h> +#include <cstdlib> +#include <cstdio> namespace vespamalloc { void info(); diff --git a/vespamalloc/src/tests/thread/racemanythreads.cpp b/vespamalloc/src/tests/thread/racemanythreads.cpp index 692228ced9e..656a7ef487a 100644 --- a/vespamalloc/src/tests/thread/racemanythreads.cpp +++ b/vespamalloc/src/tests/thread/racemanythreads.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/testapp.h> +#include <unistd.h> using namespace vespalib; diff --git a/vespamalloc/src/tests/thread/thread.cpp b/vespamalloc/src/tests/thread/thread.cpp index b121f1e513b..04be3b38b3d 100644 --- a/vespamalloc/src/tests/thread/thread.cpp +++ b/vespamalloc/src/tests/thread/thread.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <atomic> +#include <unistd.h> using namespace vespalib; |