diff options
72 files changed, 218 insertions, 978 deletions
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/StorageClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/StorageClusterTest.java index 1ac33c4a7e5..e4a02180f0e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/StorageClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/StorageClusterTest.java @@ -150,7 +150,7 @@ public class StorageClusterTest { assertEquals(7, config.num_threads()); assertFalse(config.enable_multibit_split_optimalization()); - assertEquals(1, config.num_response_threads()); + assertEquals(2, config.num_response_threads()); } { assertEquals(1, stc.getChildren().size()); @@ -180,7 +180,7 @@ public class StorageClusterTest { StorFilestorConfig.Builder builder = new StorFilestorConfig.Builder(); stc.getConfig(builder); StorFilestorConfig config = new StorFilestorConfig(builder); - assertEquals(1, config.num_response_threads()); + assertEquals(2, config.num_response_threads()); assertEquals(7, config.num_threads()); } diff --git a/configd/src/apps/sentinel/sentinel.cpp b/configd/src/apps/sentinel/sentinel.cpp index 9f179e96393..1bab29e727e 100644 --- a/configd/src/apps/sentinel/sentinel.cpp +++ b/configd/src/apps/sentinel/sentinel.cpp @@ -30,7 +30,7 @@ main(int argc, char **argv) if (c != 'c') { LOG(error, "Usage: %s -c <config-id>", argv[0]); EV_STOPPING("config-sentinel", "Bad arguments on command line"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } std::string configId(optarg); @@ -45,7 +45,7 @@ main(int argc, char **argv) if (chdir(rootDir) == -1) { LOG(error, "Fatal: Cannot cd to $ROOT (%s)", rootDir); EV_STOPPING("config-sentinel", "Cannot cd to $ROOT"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } EV_STARTED("config-sentinel"); @@ -57,7 +57,7 @@ main(int argc, char **argv) if (setenv("LC_ALL", "C", 1) != 0) { LOG(error, "Unable to set locale"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } setlocale(LC_ALL, "C"); @@ -69,15 +69,15 @@ main(int argc, char **argv) } catch (ConfigTimeoutException & ex) { LOG(warning, "Timeout getting config, please check your setup. Will exit and restart: %s", ex.getMessage().c_str()); EV_STOPPING("config-sentinel", ex.what()); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } catch (InvalidConfigException& ex) { LOG(error, "Fatal: Invalid configuration, please check your setup: %s", ex.getMessage().c_str()); EV_STOPPING("config-sentinel", ex.what()); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } catch (ConfigRuntimeException& ex) { LOG(error, "Fatal: Could not get config, please check your setup: %s", ex.getMessage().c_str()); EV_STOPPING("config-sentinel", ex.what()); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } struct timeval lastTv; @@ -91,11 +91,11 @@ main(int argc, char **argv) } catch (vespalib::PortListenException& ex) { LOG(error, "Fatal: %s", ex.getMessage().c_str()); EV_STOPPING("config-sentinel", ex.what()); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } catch (vespalib::FatalException& ex) { LOG(error, "Fatal: %s", ex.getMessage().c_str()); EV_STOPPING("config-sentinel", ex.what()); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } if (vespalib::SignalHandler::CHLD.check()) { continue; diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp index a502ce50f71..ed25cac2eee 100644 --- a/configd/src/apps/sentinel/service.cpp +++ b/configd/src/apps/sentinel/service.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/util/signalhandler.h> #include <csignal> +#include <cstdlib> #include <unistd.h> #include <fcntl.h> #include <sys/wait.h> @@ -215,7 +216,7 @@ Service::start() } EV_STARTING(name().c_str()); runChild(pipes); // This function should not return. - _exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } close(pipes[1]); // close writing end @@ -373,7 +374,7 @@ Service::runChild(int pipes[2]) snprintf(buf, sizeof buf, "open /dev/null for fd 0: got %d " "(%s)", fd, strerror(errno)); [[maybe_unused]] auto writeRes = write(pipes[1], buf, strlen(buf)); - _exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } fcntl(0, F_SETFD, 0); // Don't close on exec @@ -383,7 +384,7 @@ Service::runChild(int pipes[2]) snprintf(buf, sizeof buf, "exec error: %s for /bin/sh -c '%s'", strerror(errno), _config->command.c_str()); [[maybe_unused]] auto writeRes = write(pipes[1], buf, strlen(buf)); - _exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } const vespalib::string & diff --git a/configd/src/apps/su/main.cpp b/configd/src/apps/su/main.cpp index abef5c69036..095bbdb6844 100644 --- a/configd/src/apps/su/main.cpp +++ b/configd/src/apps/su/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char** argv) { if (argc < 2) { fprintf(stderr, "missing arguments, usage: vespa-run-as-vespa-user <cmd> [args ...]\n"); - exit(1); + return 1; } const char *username = getenv("VESPA_USER"); if (username == nullptr) { @@ -23,7 +23,7 @@ int main(int argc, char** argv) struct passwd *p = getpwnam(username); if (p == nullptr) { fprintf(stderr, "FATAL error: user '%s' missing in passwd file\n", username); - exit(1); + return 1; } gid_t g = p->pw_gid; uid_t u = p->pw_uid; @@ -33,19 +33,19 @@ int main(int argc, char** argv) if (g != oldg && setgid(g) != 0) { perror("FATAL error: could not change group id"); - exit(1); + return 1; } size_t listsize = 1; gid_t grouplist[1] = { g }; if ((g != oldg || u != oldu) && setgroups(listsize, grouplist) != 0) { perror("FATAL error: could not setgroups"); - exit(1); + return 1; } if (u != oldu && setuid(u) != 0) { perror("FATAL error: could not change user id"); - exit(1); + return 1; } execvp(argv[1], &argv[1]); perror("FATAL error: execvp failed"); - exit(1); + return 1; } diff --git a/configdefinitions/src/vespa/stor-filestor.def b/configdefinitions/src/vespa/stor-filestor.def index 5335f4f162f..5fea913316a 100644 --- a/configdefinitions/src/vespa/stor-filestor.def +++ b/configdefinitions/src/vespa/stor-filestor.def @@ -29,7 +29,7 @@ num_threads int default=8 restart ## Number of threads for response processing and delivery ## 0 will give legacy sync behavior. ## Negative number will choose a good number based on # cores. -num_response_threads int default=1 +num_response_threads int default=2 ## When merging, if we find more than this number of documents that exist on all ## of the same copies, send a separate apply bucket diff with these entries diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java index 638e3565602..2136906f205 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java @@ -87,8 +87,8 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica this.tenant = tenant; this.zkWatcherExecutor = command -> zkWatcherExecutor.execute(tenant, command); this.directoryCache = curator.createDirectoryCache(applicationsPath.getAbsolute(), false, false, zkCacheExecutor); - this.directoryCache.start(); this.directoryCache.addListener(this::childEvent); + this.directoryCache.start(); this.metrics = metrics; this.reloadListener = reloadListener; this.responseFactory = ConfigResponseFactory.create(configserverConfig); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java index 33ce8f52834..e7888f2663b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java @@ -118,8 +118,8 @@ public class TenantRepository { if (useZooKeeperWatchForTenantChanges) { this.directoryCache = Optional.of(curator.createDirectoryCache(tenantsPath.getAbsolute(), false, false, zkCacheExecutor)); - this.directoryCache.get().start(); this.directoryCache.get().addListener(this::childEvent); + this.directoryCache.get().start(); } else { this.directoryCache = Optional.empty(); } diff --git a/configutil/src/apps/configstatus/main.cpp b/configutil/src/apps/configstatus/main.cpp index d1159a5e33c..befd0e649f6 100644 --- a/configutil/src/apps/configstatus/main.cpp +++ b/configutil/src/apps/configstatus/main.cpp @@ -3,7 +3,8 @@ #include <vespa/defaults.h> #include <vespa/vespalib/text/stringtokenizer.h> #include <iostream> -#include <lib/configstatus.h> +#include <cstdlib> +#include "lib/configstatus.h" #include <vespa/fastos/app.h> #include <vespa/log/log.h> @@ -48,13 +49,13 @@ int Application::parseOpts() { break; case 'h': usage(); - exit(0); + std::_Exit(0); case 'f': _flags.host_filter = parse_host_set(optArg); break; default: usage(); - exit(1); + std::_Exit(1); } } if (_specString.empty()) { diff --git a/configutil/src/apps/modelinspect/main.cpp b/configutil/src/apps/modelinspect/main.cpp index 0404cf0ae86..c43294be8de 100644 --- a/configutil/src/apps/modelinspect/main.cpp +++ b/configutil/src/apps/modelinspect/main.cpp @@ -2,7 +2,8 @@ #include <vespa/defaults.h> #include <iostream> -#include <lib/modelinspect.h> +#include <cstdlib> +#include "lib/modelinspect.h" #include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/fastos/app.h> @@ -56,7 +57,7 @@ Application::parseOpts() return _argc; default: usage(); - exit(1); + std::_Exit(1); } } if (_specString.empty()) { @@ -84,7 +85,7 @@ Application::getConfigUri() } catch (std::exception &e) { std::cerr << "FATAL ERROR: failed to set up model configuration: " << e.what() << "\n"; - exit(1); + std::_Exit(1); } } diff --git a/configutil/src/lib/configstatus.cpp b/configutil/src/lib/configstatus.cpp index 1831a39b18a..415edf6defc 100644 --- a/configutil/src/lib/configstatus.cpp +++ b/configutil/src/lib/configstatus.cpp @@ -9,6 +9,7 @@ #include <vbench/http/http_client.h> #include <vespa/config/common/exceptions.h> #include <iostream> +#include <cstdlib> using configdefinitions::tagsContain; @@ -129,7 +130,7 @@ ConfigStatus::ConfigStatus(Flags flags, const config::ConfigUri uri) if (_cfg.get() == NULL) { std::cerr << "FATAL ERROR: failed to get model configuration." << std::endl; - exit(1); + std::_Exit(1); } } diff --git a/configutil/src/lib/modelinspect.cpp b/configutil/src/lib/modelinspect.cpp index bf0536a9d4c..db5709cc95b 100644 --- a/configutil/src/lib/modelinspect.cpp +++ b/configutil/src/lib/modelinspect.cpp @@ -6,6 +6,7 @@ #include <vespa/config/common/exceptions.h> #include <iostream> #include <algorithm> +#include <cstdlib> using configdefinitions::tagsContain; using configdefinitions::upcase; @@ -35,7 +36,7 @@ ModelInspect::ModelInspect(Flags flags, const config::ConfigUri uri, std::ostrea if (_flags.verbose) std::cerr << "success!\n"; } else { std::cerr << "FATAL ERROR: failed to get model configuration.\n"; - exit(1); + std::_Exit(1); } } diff --git a/fastlib/src/vespa/fastlib/text/apps/extcase.cpp b/fastlib/src/vespa/fastlib/text/apps/extcase.cpp index b713523af08..63ec841f84c 100644 --- a/fastlib/src/vespa/fastlib/text/apps/extcase.cpp +++ b/fastlib/src/vespa/fastlib/text/apps/extcase.cpp @@ -166,7 +166,5 @@ main(int argc, char **argv) file.Close(); DumpCase(); - - exit(0); return 0; } diff --git a/fastos/src/vespa/fastos/file.cpp b/fastos/src/vespa/fastos/file.cpp index 861dd9f4259..cacdf4da836 100644 --- a/fastos/src/vespa/fastos/file.cpp +++ b/fastos/src/vespa/fastos/file.cpp @@ -10,6 +10,7 @@ #include <sstream> #include <cstring> #include <fcntl.h> +#include <cstdlib> DirectIOException::DirectIOException(const char * fileName, const void * buffer, size_t length, int64_t offset) : std::exception(), @@ -339,19 +340,19 @@ FastOS_FileInterface::MakeDirIfNotPresentOrExit(const char *name) return; fprintf(stderr, "%s is not a directory\n", name); - exit(1); + std::_Exit(1); } if (statInfo._error != FastOS_StatInfo::FileNotFound) { std::error_code ec(errno, std::system_category()); fprintf(stderr, "Could not stat %s: %s\n", name, ec.message().c_str()); - exit(1); + std::_Exit(1); } if (!FastOS_File::MakeDirectory(name)) { std::error_code ec(errno, std::system_category()); fprintf(stderr, "Could not mkdir(\"%s\", 0775): %s\n", name, ec.message().c_str()); - exit(1); + std::_Exit(1); } } diff --git a/fastos/src/vespa/fastos/unix_ipc.cpp b/fastos/src/vespa/fastos/unix_ipc.cpp index 4c8e3102dbb..09f8e6162f7 100644 --- a/fastos/src/vespa/fastos/unix_ipc.cpp +++ b/fastos/src/vespa/fastos/unix_ipc.cpp @@ -3,6 +3,7 @@ #include "ringbuffer.h" #include <cassert> #include <cstring> +#include <cstdlib> #include <unistd.h> #include <fcntl.h> #include <memory> @@ -21,7 +22,7 @@ FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, int descriptor) if(pipe(_wakeupPipe) != 0) { perror("pipe wakeuppipe"); - exit(1); + std::_Exit(1); } else { SetBlocking(_wakeupPipe[0], false); SetBlocking(_wakeupPipe[1], true); @@ -536,10 +537,10 @@ Run(FastOS_ThreadInterface *thisThread, void *arg) if ((fds[i].events & POLLOUT) != 0) printf("Write %d\n", fds[i].fd); } - exit(1); - } - else + std::_Exit(1); + } else { break; + } } bool woken = false; diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp index 087f800e668..b66d5ce8346 100644 --- a/fastos/src/vespa/fastos/unix_process.cpp +++ b/fastos/src/vespa/fastos/unix_process.cpp @@ -4,6 +4,7 @@ #include "ringbuffer.h" #include <vector> #include <cstring> +#include <cstdlib> #include <unistd.h> #include <fcntl.h> #include <sys/socket.h> @@ -947,12 +948,12 @@ ReadBytes(int fd, void *buffer, int bytes) if (bytesRead < 0) { //perror("FATAL: FastOS_UNIX_ProcessStarter read"); - exit(1); + std::_Exit(1); } else if(bytesRead == 0) { //fprintf(stderr, "FATAL: FastOS_UNIX_RealProcessStart read 0\n"); - exit(1); + std::_Exit(1); } writePtr += bytesRead; @@ -977,12 +978,12 @@ WriteBytes(int fd, const void *buffer, int bytes, bool ignoreFailure) if (ignoreFailure) return; //perror("FATAL: FastOS_UNIX_ProcessStarter write"); - exit(1); + std::_Exit(1); } else if (bytesWritten == 0) { if (ignoreFailure) return; //fprintf(stderr, "FATAL: FastOS_UNIX_RealProcessStart write 0\n"); - exit(1); + std::_Exit(1); } readPtr += bytesWritten; diff --git a/fbench/src/fbench/fbench.cpp b/fbench/src/fbench/fbench.cpp index 88d27a33bd7..efac34409cc 100644 --- a/fbench/src/fbench/fbench.cpp +++ b/fbench/src/fbench/fbench.cpp @@ -14,6 +14,7 @@ #include <cmath> #include <csignal> #include <cinttypes> +#include <cstdlib> namespace { @@ -327,7 +328,7 @@ FBench::Exit() StopClients(); printf("\n"); PrintSummary(); - exit(0); + std::_Exit(0); } int diff --git a/fsa/queryproc/count_plain_grams.cpp b/fsa/queryproc/count_plain_grams.cpp index ef400db9bc4..ffb5c730cdc 100644 --- a/fsa/queryproc/count_plain_grams.cpp +++ b/fsa/queryproc/count_plain_grams.cpp @@ -43,7 +43,7 @@ int main(int argc, char **argv) if(argc!=2){ std::cerr << "usage: " << argv[0] << " fsa_file" << std::endl; - exit(1); + return 1; } FSA fsa(argv[1]); diff --git a/fsa/queryproc/count_sorted_grams.cpp b/fsa/queryproc/count_sorted_grams.cpp index cd047633e72..84350068f69 100644 --- a/fsa/queryproc/count_sorted_grams.cpp +++ b/fsa/queryproc/count_sorted_grams.cpp @@ -28,7 +28,7 @@ int main(int argc, char **argv) if(argc!=2){ std::cerr << "usage: " << argv[0] << " sorted_fsa_file" << std::endl; - exit(1); + return 1; } FSA fsa(argv[1]); diff --git a/fsa/queryproc/p2s_ratio.cpp b/fsa/queryproc/p2s_ratio.cpp index 830985813a8..9238df6eddc 100644 --- a/fsa/queryproc/p2s_ratio.cpp +++ b/fsa/queryproc/p2s_ratio.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) if(argc!=3){ std::cerr << "usage: " << argv[0] << " plain_count_fsa_file sorted_count_fsa_file" << std::endl; - exit(1); + return 1; } FSA plain_fsa(argv[1]); diff --git a/fsa/src/alltest/conceptnet_test.cpp b/fsa/src/alltest/conceptnet_test.cpp index 157903fcd4e..03a88434776 100644 --- a/fsa/src/alltest/conceptnet_test.cpp +++ b/fsa/src/alltest/conceptnet_test.cpp @@ -29,13 +29,13 @@ int main(int argc, char **argv) break; case '?': fprintf(stderr,"conceptnet_test: unrecognized option"); - exit(1); + return 1; } } if(optind>=argc){ fprintf(stderr,"usage: conceptnet_test [-aec] DOMAIN [UNIT ...]\n"); - exit(1); + return 1; } std::string domain = argv[optind]; @@ -44,7 +44,7 @@ int main(int argc, char **argv) domain + ".fsa", domain + ".dat")){ fprintf(stderr,"failed to load concept net %s\n",domain.c_str()); - exit(1); + return 1; } ConceptNet::Handle* cn = ConceptNetManager::instance().get(domain); @@ -71,10 +71,9 @@ int main(int argc, char **argv) } } } - } - else { + } else { fprintf(stderr,"failed to load concept net %s\n",domain.c_str()); - exit(1); + return 1; } - + return 0; } diff --git a/fsa/src/alltest/fsamanager_test.cpp b/fsa/src/alltest/fsamanager_test.cpp index aee97432347..a4d8b234415 100644 --- a/fsa/src/alltest/fsamanager_test.cpp +++ b/fsa/src/alltest/fsamanager_test.cpp @@ -12,7 +12,7 @@ int main(int argc, char** argv) { if(argc<3){ std::cerr << "usage: fsamanager_test cache_dir fsa_file_or_url [fsa_file_or_url ...]\n"; - exit(1); + return 1; } FSAManager::instance().setCacheDir(argv[1]); diff --git a/fsa/src/alltest/lookup_test.cpp b/fsa/src/alltest/lookup_test.cpp index dcb570f09a2..dcc20075a98 100644 --- a/fsa/src/alltest/lookup_test.cpp +++ b/fsa/src/alltest/lookup_test.cpp @@ -20,7 +20,7 @@ int main(int argc, char** argv) if(argc!=2){ std::cerr << "usage: lookup_test fsafile <input >output" << std::endl; - exit(1); + return 1; } FSA f(argv[1]); diff --git a/fsa/src/apps/fsadump/fsadump.cpp b/fsa/src/apps/fsadump/fsadump.cpp index 16e128f33ca..5308f113356 100644 --- a/fsa/src/apps/fsadump/fsadump.cpp +++ b/fsa/src/apps/fsadump/fsadump.cpp @@ -80,10 +80,10 @@ int main(int argc, char** argv) break; case 'h': usage(argv[0]); - exit(0); + return 0; case 'V': version(); - exit(0); + return 0; case 't': format = OUTPUT_TEXT; break; @@ -101,13 +101,13 @@ int main(int argc, char** argv) break; case '?': usage(argv[0],"unrecognized option"); - exit(1); + return 1; } } if(optind!=argc-1){ usage(argv[0],"required parameter(s) missing"); - exit(1); + return 1; } if(format==OUTPUT_UNDEF) // use default format (warning?) @@ -119,7 +119,7 @@ int main(int argc, char** argv) if(!fsa.isOk()){ std::cerr << "Failed to open fsa file (" << input_file << ")" << std::endl; - exit(1); + return 1; } std::string meta,temp; diff --git a/fsa/src/apps/fsainfo/fsainfo.cpp b/fsa/src/apps/fsainfo/fsainfo.cpp index 31b23c17401..61af267545b 100644 --- a/fsa/src/apps/fsainfo/fsainfo.cpp +++ b/fsa/src/apps/fsainfo/fsainfo.cpp @@ -48,19 +48,19 @@ int main(int argc, char** argv) switch(opt){ case 'h': usage(argv[0]); - exit(0); + return 0; case 'V': version(); - exit(0); + return 0; case '?': usage(argv[0],"unrecognized option"); - exit(1); + return 1; } } if(optind!=argc-1){ usage(argv[0],"required parameter fsa is missing"); - exit(1); + return 1; } fsa_file = argv[optind]; diff --git a/fsa/src/apps/makefsa/makefsa.cpp b/fsa/src/apps/makefsa/makefsa.cpp index 59b7e2c27d0..f86a0d781c1 100644 --- a/fsa/src/apps/makefsa/makefsa.cpp +++ b/fsa/src/apps/makefsa/makefsa.cpp @@ -87,10 +87,10 @@ int main(int argc, char** argv) break; case 'h': usage(argv[0]); - exit(0); + return 0; case 'V': version(); - exit(0); + return 0; case 't': format = INPUT_TEXT; break; @@ -101,7 +101,7 @@ int main(int argc, char** argv) num_size = strtoul(optarg,NULL,0); if(num_size!=1 && num_size!=2 && num_size!=4){ usage(argv[0],"invalid numerical info size (-s)"); - exit(1); + return 1; } break; case 'z': @@ -124,7 +124,7 @@ int main(int argc, char** argv) break; case '?': usage(argv[0],"unrecognized option"); - exit(1); + return 1; } } @@ -141,7 +141,7 @@ int main(int argc, char** argv) } else{ usage(argv[0],"required parameter(s) missing"); - exit(1); + return 1; } Automaton automaton; diff --git a/logd/src/tests/rotate/dummyserver.cpp b/logd/src/tests/rotate/dummyserver.cpp index 4a52154f37c..f3458edaf80 100644 --- a/logd/src/tests/rotate/dummyserver.cpp +++ b/logd/src/tests/rotate/dummyserver.cpp @@ -9,11 +9,12 @@ #include <time.h> #include <fcntl.h> #include <vespa/vespalib/net/socket_address.h> +#include <cstdlib> void error(const char *msg) { perror(msg); - exit(1); + std::_Exit(1); } int main(int /*argc*/, char ** /*argv*/) diff --git a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp index e37a6fb2dcb..a149c6581ac 100644 --- a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp +++ b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.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 "cf-handler.h" +#include <cstdlib> #include <dirent.h> #include <stdio.h> #include <unistd.h> @@ -122,12 +123,12 @@ CfHandler::start(const char *configId) subscribe(configId, CONFIG_TIMEOUT_MS); } catch (config::ConfigTimeoutException & ex) { LOG(warning, "Timout getting config, please check your setup. Will exit and restart: %s", ex.getMessage().c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } catch (config::InvalidConfigException& ex) { LOG(error, "Fatal: Invalid configuration, please check your setup: %s", ex.getMessage().c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } catch (config::ConfigRuntimeException& ex) { LOG(error, "Fatal: Could not get config, please check your setup: %s", ex.getMessage().c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } } diff --git a/logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp b/logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp index c5c19aa2c3f..9a4fb5d1d29 100644 --- a/logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp +++ b/logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp @@ -8,6 +8,7 @@ #include <sys/wait.h> #include <vector> #include <string> +#include <cstdlib> #include <vespa/log/log.h> LOG_SETUP(".child-handler"); @@ -44,7 +45,7 @@ runSplunk(const vespalib::string &prefix, std::vector<const char *> args) execv(cargv[0], cargv); // if execv fails: perror(cargv[0]); - exit(1); + std::_Exit(1); } LOG(debug, "child running with pid %d", (int)child); int waitStatus = 0; diff --git a/logforwarder/src/apps/vespa-logforwarder-start/main.cpp b/logforwarder/src/apps/vespa-logforwarder-start/main.cpp index 8fc74fcac8e..859a8f4dd3f 100644 --- a/logforwarder/src/apps/vespa-logforwarder-start/main.cpp +++ b/logforwarder/src/apps/vespa-logforwarder-start/main.cpp @@ -30,7 +30,7 @@ main(int argc, char** argv) int c = getopt(argc, argv, "c:"); if (c != 'c') { LOG(error, "Usage: %s -c <config-id>", argv[0]); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } Wrapper wrapper(optarg); wrapper.run(); diff --git a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp index dcd3dce218b..c669f90ae2c 100644 --- a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp +++ b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp @@ -10,6 +10,7 @@ #include <vespa/fastos/app.h> #include <sys/time.h> #include <thread> +#include <cstdlib> #include <vespa/log/log.h> LOG_SETUP("vespa-proton-cmd"); @@ -123,7 +124,7 @@ public: if (!sbmirror.ready()) { fprintf(stderr, "ERROR: no data from service location broker\n"); - exit(1); + std::_Exit(1); } slobrok::api::MirrorAPI::SpecList specs = sbmirror.lookup(rtcPattern); slobrok::api::MirrorAPI::SpecList specs2 = sbmirror.lookup(rtcPattern2); @@ -140,7 +141,7 @@ public: scanSpecs(specs3, me, service, spec, found); if (found > 1) { fprintf(stderr, "found more than one local RTC, you must use --id=<name>\n"); - exit(1); + std::_Exit(1); } if (found < 1) { fprintf(stderr, "found no local RTC, you must use --id=<name> (list follows):\n"); @@ -148,12 +149,12 @@ public: printf("RTC name %s with connection spec %s\n", specs[j].first.c_str(), specs[j].second.c_str()); } - exit(1); + std::_Exit(1); } return spec; } catch (config::InvalidConfigException& e) { fprintf(stderr, "ERROR: failed to get service location broker configuration\n"); - exit(1); + std::_Exit(1); } return ""; } 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 90953f78c40..06fb5e71e06 100644 --- a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp +++ b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp @@ -15,6 +15,7 @@ #include <vespa/fastos/app.h> #include <iostream> #include <getopt.h> +#include <cstdlib> #include <vespa/log/log.h> LOG_SETUP("vespa-index-inspect"); @@ -153,10 +154,8 @@ FieldOptions::validateFields(const Schema &schema) i != ie; ++i) { uint32_t fieldId = schema.getIndexFieldId(*i); if (fieldId == Schema::UNKNOWN_FIELD_ID) { - LOG(error, - "No such field: %s", - i->c_str()); - exit(1); + LOG(error, "No such field: %s", i->c_str()); + std::_Exit(1); } _ids.push_back(fieldId); } @@ -465,7 +464,7 @@ ShowPostingListSubApp::showTransposedPostingList() if (!schema.loadFromFile(schemaName)) { LOG(error, "Could not load schema from %s", schemaName.c_str()); - exit(1); + std::_Exit(1); } _fieldOptions.validateFields(schema); if (!readDocIdLimit(schema)) @@ -538,14 +537,14 @@ ShowPostingListSubApp::showPostingList() if (!schema.loadFromFile(schemaName)) { LOG(error, "Could not load schema from %s", schemaName.c_str()); - exit(1); + std::_Exit(1); } _fieldOptions.validateFields(schema); if (_fieldOptions._ids.size() != 1) { LOG(error, "Wrong number of field arguments: %d", static_cast<int>(_fieldOptions._ids.size())); - exit(1); + std::_Exit(1); } SchemaUtil::IndexIterator it(schema, _fieldOptions._ids.front()); @@ -559,26 +558,22 @@ ShowPostingListSubApp::showPostingList() if (_readmmap) tuneFileRead.setWantMemoryMap(); if (!dict->open(dictName, tuneFileRead)) { - LOG(error, - "Could not open dictionary %s", - dictName.c_str()); - exit(1); + LOG(error, "Could not open dictionary %s", dictName.c_str()); + std::_Exit(1); } std::unique_ptr<PostingListFileRandRead> postingfile(new Zc4PosOccRandRead); std::string mangledName = _indexDir + "/" + shortName + "/posocc.dat.compressed"; if (!postingfile->open(mangledName, tuneFileRead)) { - LOG(error, - "Could not open posting list file %s", - mangledName.c_str()); - exit(1); + LOG(error, "Could not open posting list file %s", mangledName.c_str()); + std::_Exit(1); } PostingListOffsetAndCounts offsetAndCounts; uint64_t wordNum = 0; bool res = dict->lookup(_word, wordNum, offsetAndCounts); if (!res) { LOG(warning, "Unknown word %s", _word.c_str()); - exit(1); + std::_Exit(1); } if (_verbose) { LOG(info, @@ -650,15 +645,13 @@ ShowPostingListSubApp::showPostingList() } if (!postingfile->close()) { - LOG(error, - "Could not close posting list file %s", + LOG(error, "Could not close posting list file %s", mangledName.c_str()); - exit(1); + std::_Exit(1); } if (!dict->close()) { - LOG(error, - "Could not close dictionary %s", dictName.c_str()); - exit(1); + LOG(error, "Could not close dictionary %s", dictName.c_str()); + std::_Exit(1); } } @@ -797,16 +790,14 @@ DumpWordsSubApp::dumpWords() search::index::Schema schema; std::string schemaName = _indexDir + "/schema.txt"; if (!schema.loadFromFile(schemaName)) { - LOG(error, - "Could not load schema from %s", schemaName.c_str()); - exit(1); + LOG(error, "Could not load schema from %s", schemaName.c_str()); + std::_Exit(1); } _fieldOptions.validateFields(schema); if (_fieldOptions._ids.size() != 1) { - LOG(error, - "Wrong number of field arguments: %d", + LOG(error, "Wrong number of field arguments: %d", static_cast<int>(_fieldOptions._ids.size())); - exit(1); + std::_Exit(1); } SchemaUtil::IndexIterator index(schema, _fieldOptions._ids[0]); @@ -815,9 +806,8 @@ DumpWordsSubApp::dumpWords() std::string wordListName = fieldDir + "/dictionary"; search::TuneFileSeqRead tuneFileRead; if (!wordList.open(wordListName, tuneFileRead)) { - LOG(error, - "Could not open wordlist %s", wordListName.c_str()); - exit(1); + LOG(error, "Could not open wordlist %s", wordListName.c_str()); + std::_Exit(1); } uint64_t wordNum = 0; vespalib::string word; @@ -838,9 +828,8 @@ DumpWordsSubApp::dumpWords() std::cout << '\n'; } if (!wordList.close()) { - LOG(error, - "Could not close wordlist %s", wordListName.c_str()); - exit(1); + LOG(error, "Could not close wordlist %s", wordListName.c_str()); + std::_Exit(1); } } diff --git a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp index 1e10d94bb18..9c896396de3 100644 --- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp @@ -82,7 +82,7 @@ void read_vector_file(MallocPointVector *p) { int fd = open(fn.c_str(), O_RDONLY); if (fd < 0) { perror(fn.c_str()); - exit(1); + std::_Exit(1); } int d; size_t rv; diff --git a/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp b/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp index 9b2510ac3df..4abbe7d2613 100644 --- a/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp +++ b/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp @@ -18,7 +18,7 @@ ExtractKeywordsTest::Main() bool failed = false; if (_argc == 1) - Usage(_argv[0]); + return Usage(_argv[0]); // default initialize to not run any tests. for (int n = 0; n < NUMTESTS; n++) @@ -271,7 +271,7 @@ ExtractKeywordsTest::RunTest(int testno, bool verify) return result; } -void +int ExtractKeywordsTest::Usage(char *progname) { printf("%s {testnospec}+\n\ @@ -279,7 +279,7 @@ ExtractKeywordsTest::Usage(char *progname) num: single test\n\ num-num: inclusive range (open range permitted)\n",progname); printf("There are tests from %d to %d\n\n", 0, NUMTESTS-1); - exit(-1); + return EXIT_FAILURE; } int diff --git a/searchsummary/src/tests/extractkeywords/extractkeywordstest.h b/searchsummary/src/tests/extractkeywords/extractkeywordstest.h index e3c79bfc202..739ba4bf1ff 100644 --- a/searchsummary/src/tests/extractkeywords/extractkeywordstest.h +++ b/searchsummary/src/tests/extractkeywords/extractkeywordstest.h @@ -15,7 +15,7 @@ private: search::docsummary::KeywordExtractor *_extractor; int Main() override; - void Usage(char *progname); + int Usage(char *progname); bool ShowResult(int testNo, const char *actual, const char *correct); bool RunTest(int i, bool verify); diff --git a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp index fbaa5581173..04a811494c9 100644 --- a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp +++ b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/util/shutdownguard.h> #include <unistd.h> #include <sys/wait.h> +#include <cstdlib> using namespace vespalib; @@ -23,7 +24,7 @@ Test::Main() for (int i = 0; i < 1000; ++i) { std::this_thread::sleep_for(20ms); } - exit(0); + std::_Exit(0); } for (int i = 0; i < 1000; ++i) { std::this_thread::sleep_for(20ms); diff --git a/storage/src/tests/distributor/CMakeLists.txt b/storage/src/tests/distributor/CMakeLists.txt index 1403021a9c3..f983fb32e1c 100644 --- a/storage/src/tests/distributor/CMakeLists.txt +++ b/storage/src/tests/distributor/CMakeLists.txt @@ -22,7 +22,6 @@ vespa_add_executable(storage_distributor_gtest_runner_app TEST idealstatemanagertest.cpp joinbuckettest.cpp maintenanceschedulertest.cpp - mapbucketdatabasetest.cpp mergelimitertest.cpp mergeoperationtest.cpp nodeinfotest.cpp diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp index b110e99f8a4..0da860d0542 100644 --- a/storage/src/tests/distributor/distributortest.cpp +++ b/storage/src/tests/distributor/distributortest.cpp @@ -1072,7 +1072,7 @@ TEST_F(DistributorTest, pending_to_no_pending_global_merges_edge_immediately_sen } TEST_F(DistributorTest, stale_reads_config_is_propagated_to_external_operation_handler) { - createLinks(true); + createLinks(); setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); configure_stale_reads_enabled(true); @@ -1083,7 +1083,7 @@ TEST_F(DistributorTest, stale_reads_config_is_propagated_to_external_operation_h } TEST_F(DistributorTest, fast_path_on_consistent_gets_config_is_propagated_to_internal_config) { - createLinks(true); + createLinks(); setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); configure_update_fast_path_restart_enabled(true); @@ -1094,7 +1094,7 @@ TEST_F(DistributorTest, fast_path_on_consistent_gets_config_is_propagated_to_int } TEST_F(DistributorTest, merge_disabling_config_is_propagated_to_internal_config) { - createLinks(true); + createLinks(); setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); configure_merge_operations_disabled(true); @@ -1105,7 +1105,7 @@ TEST_F(DistributorTest, merge_disabling_config_is_propagated_to_internal_config) } TEST_F(DistributorTest, metadata_update_phase_config_is_propagated_to_internal_config) { - createLinks(true); + createLinks(); setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); configure_metadata_update_phase_enabled(true); @@ -1116,7 +1116,7 @@ TEST_F(DistributorTest, metadata_update_phase_config_is_propagated_to_internal_c } TEST_F(DistributorTest, weak_internal_read_consistency_config_is_propagated_to_internal_configs) { - createLinks(true); + createLinks(); setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); configure_use_weak_internal_read_consistency(true); @@ -1128,15 +1128,8 @@ TEST_F(DistributorTest, weak_internal_read_consistency_config_is_propagated_to_i EXPECT_FALSE(getExternalOperationHandler().use_weak_internal_read_consistency_for_gets()); } -TEST_F(DistributorTest, concurrent_reads_not_enabled_if_btree_db_is_not_enabled) { - createLinks(false); - setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); - configure_stale_reads_enabled(true); - EXPECT_FALSE(getExternalOperationHandler().concurrent_gets_enabled()); -} - void DistributorTest::set_up_and_start_get_op_with_stale_reads_enabled(bool enabled) { - createLinks(true); + createLinks(); setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); configure_stale_reads_enabled(enabled); @@ -1145,7 +1138,7 @@ void DistributorTest::set_up_and_start_get_op_with_stale_reads_enabled(bool enab _distributor->onDown(make_dummy_get_command_for_bucket_1()); } -TEST_F(DistributorTest, gets_are_started_outside_main_distributor_logic_if_btree_db_and_stale_reads_enabled) { +TEST_F(DistributorTest, gets_are_started_outside_main_distributor_logic_if_stale_reads_enabled) { set_up_and_start_get_op_with_stale_reads_enabled(true); ASSERT_THAT(_sender.commands(), SizeIs(1)); EXPECT_THAT(_sender.replies(), SizeIs(0)); diff --git a/storage/src/tests/distributor/distributortestutil.cpp b/storage/src/tests/distributor/distributortestutil.cpp index 9f0c56c3fa5..3c26ea01c19 100644 --- a/storage/src/tests/distributor/distributortestutil.cpp +++ b/storage/src/tests/distributor/distributortestutil.cpp @@ -20,7 +20,7 @@ DistributorTestUtil::DistributorTestUtil() DistributorTestUtil::~DistributorTestUtil() { } void -DistributorTestUtil::createLinks(bool use_btree_db) +DistributorTestUtil::createLinks() { _node.reset(new TestDistributorApp(_config.getConfigId())); _threadPool = framework::TickingThreadPool::createDefault("distributor"); @@ -29,7 +29,6 @@ DistributorTestUtil::createLinks(bool use_btree_db) *_threadPool, *this, true, - use_btree_db, _hostInfo, &_messageSender)); _component.reset(new storage::DistributorComponent(_node->getComponentRegister(), "distrtestutil")); diff --git a/storage/src/tests/distributor/distributortestutil.h b/storage/src/tests/distributor/distributortestutil.h index a6e7ea16798..3dc71bcb433 100644 --- a/storage/src/tests/distributor/distributortestutil.h +++ b/storage/src/tests/distributor/distributortestutil.h @@ -34,7 +34,7 @@ public: /** * Sets up the storage link chain. */ - void createLinks(bool use_btree_db = false); + void createLinks(); void setTypeRepo(const std::shared_ptr<const document::DocumentTypeRepo> &repo); void close(); diff --git a/storage/src/tests/distributor/maintenanceschedulertest.cpp b/storage/src/tests/distributor/maintenanceschedulertest.cpp index 53408bbf6b6..f4b1b687158 100644 --- a/storage/src/tests/distributor/maintenanceschedulertest.cpp +++ b/storage/src/tests/distributor/maintenanceschedulertest.cpp @@ -2,7 +2,6 @@ #include <vespa/document/test/make_document_bucket.h> #include <vespa/storage/distributor/maintenance/simplebucketprioritydatabase.h> #include <vespa/storage/distributor/maintenance/maintenancescheduler.h> -#include <vespa/storage/bucketdb/mapbucketdatabase.h> #include <tests/distributor/maintenancemocks.h> #include <vespa/vespalib/gtest/gtest.h> #include <memory> diff --git a/storage/src/tests/distributor/mapbucketdatabasetest.cpp b/storage/src/tests/distributor/mapbucketdatabasetest.cpp deleted file mode 100644 index 2c000f6b5db..00000000000 --- a/storage/src/tests/distributor/mapbucketdatabasetest.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/storage/bucketdb/mapbucketdatabase.h> -#include <tests/distributor/bucketdatabasetest.h> - -namespace storage::distributor { - -VESPA_GTEST_INSTANTIATE_TEST_SUITE_P(MapDatabase, BucketDatabaseTest, - ::testing::Values(std::make_shared<MapBucketDatabase>())); - -} diff --git a/storage/src/tests/distributor/simplemaintenancescannertest.cpp b/storage/src/tests/distributor/simplemaintenancescannertest.cpp index abf061dd990..b21a10c319e 100644 --- a/storage/src/tests/distributor/simplemaintenancescannertest.cpp +++ b/storage/src/tests/distributor/simplemaintenancescannertest.cpp @@ -36,7 +36,7 @@ void SimpleMaintenanceScannerTest::SetUp() { _priorityGenerator = std::make_unique<MockMaintenancePriorityGenerator>(); - _bucketSpaceRepo = std::make_unique<DistributorBucketSpaceRepo>(false); + _bucketSpaceRepo = std::make_unique<DistributorBucketSpaceRepo>(); _priorityDb = std::make_unique<SimpleBucketPriorityDatabase>(); _scanner = std::make_unique<SimpleMaintenanceScanner>(*_priorityDb, *_priorityGenerator, *_bucketSpaceRepo); } @@ -79,7 +79,7 @@ TEST_F(SimpleMaintenanceScannerTest, prioritize_single_bucket) { TEST_F(SimpleMaintenanceScannerTest, prioritize_single_bucket_alt_bucket_space) { document::BucketSpace bucketSpace(4); - _bucketSpaceRepo->add(bucketSpace, std::make_unique<DistributorBucketSpace>(false)); + _bucketSpaceRepo->add(bucketSpace, std::make_unique<DistributorBucketSpace>()); _scanner->reset(); addBucketToDb(bucketSpace, 1); std::string expected("PrioritizedBucket(Bucket(BucketSpace(0x0000000000000004), BucketId(0x4000000000000001)), pri VERY_HIGH)\n"); diff --git a/storage/src/vespa/storage/bucketdb/CMakeLists.txt b/storage/src/vespa/storage/bucketdb/CMakeLists.txt index 5bd966ae0e1..abf310d9bae 100644 --- a/storage/src/vespa/storage/bucketdb/CMakeLists.txt +++ b/storage/src/vespa/storage/bucketdb/CMakeLists.txt @@ -11,7 +11,6 @@ vespa_add_library(storage_bucketdb OBJECT generic_btree_bucket_database.cpp judyarray.cpp lockablemap.cpp - mapbucketdatabase.cpp storagebucketdbinitializer.cpp storbucketdb.cpp DEPENDS diff --git a/storage/src/vespa/storage/bucketdb/mapbucketdatabase.cpp b/storage/src/vespa/storage/bucketdb/mapbucketdatabase.cpp deleted file mode 100644 index 7556b80b29c..00000000000 --- a/storage/src/vespa/storage/bucketdb/mapbucketdatabase.cpp +++ /dev/null @@ -1,625 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "mapbucketdatabase.h" -#include <vespa/storage/common/bucketoperationlogger.h> -#include <vespa/vespalib/util/backtrace.h> -#include <ostream> -#include <cassert> - -#include <vespa/log/bufferedlogger.h> -LOG_SETUP(".mapbucketdatabase"); - -namespace storage { - -MapBucketDatabase::MapBucketDatabase() -{ - // Allocate the root element. - allocate(); -} - -MapBucketDatabase::~MapBucketDatabase() {} - -MapBucketDatabase::E::~E() { } - -uint32_t -MapBucketDatabase::allocate() -{ - if (!_free.empty()) { - uint32_t retVal = _free[_free.size() - 1]; - _free.pop_back(); - return retVal; - } - - _db.push_back(E()); - return _db.size() - 1; -} - -uint32_t -MapBucketDatabase::allocateValue(const document::BucketId& bid) -{ - if (!_freeValues.empty()) { - uint32_t retVal = _freeValues[_freeValues.size() - 1]; - _freeValues.pop_back(); - return retVal; - } - - _values.push_back(BucketDatabase::Entry(bid)); - return _values.size() - 1; -} - -BucketDatabase::Entry* -MapBucketDatabase::find(int index, uint8_t bitCount, - const document::BucketId& bid, bool create) -{ - if (index == -1) { - return NULL; - } - - E& e = _db[index]; - if (bitCount == bid.getUsedBits()) { - if (e.value == -1) { - if (create) { - e.value = allocateValue(bid); - } else { - return NULL; - } - } - - return &_values[e.value]; - } - - // Must reference _db[index] rather than E, since the address of E may change - // in allocate(). - if (bid.getBit(bitCount) == 0) { - if (e.e_0 == -1 && create) { - int val = allocate(); - _db[index].e_0 = val; - } - - return find(_db[index].e_0, bitCount + 1, bid, create); - } else { - if (e.e_1 == -1 && create) { - int val = allocate(); - _db[index].e_1 = val; - } - - return find(_db[index].e_1, bitCount + 1, bid, create); - } -} - -BucketDatabase::Entry -MapBucketDatabase::get(const document::BucketId& bucket) const -{ - MapBucketDatabase& mutableSelf(const_cast<MapBucketDatabase&>(*this)); - Entry* found = mutableSelf.find(0, 0, bucket, false); - if (found) { - return *found; - } else { - return BucketDatabase::Entry(); - } -} - -bool -MapBucketDatabase::remove(int index, - uint8_t bitCount, - const document::BucketId& bid) -{ - if (index == -1) { - return false; - } - - E& e = _db[index]; - if (bitCount == bid.getUsedBits()) { - if (e.value != -1) { - _freeValues.push_back(e.value); - e.value = -1; - } - } - - if (bid.getBit(bitCount) == 0) { - if (remove(e.e_0, bitCount + 1, bid)) { - e.e_0 = -1; - } - } else { - if (remove(e.e_1, bitCount + 1, bid)) { - e.e_1 = -1; - } - } - - if (e.empty() && index > 0) { - _free.push_back(index); - return true; - } else { - return false; - } -} - -void -MapBucketDatabase::remove(const document::BucketId& bucket) -{ - LOG_BUCKET_OPERATION_NO_LOCK(bucket, "REMOVING from bucket db!"); - remove(0, 0, bucket); -} - -namespace { - -void __attribute__((noinline)) log_empty_bucket_insertion(const document::BucketId& id) { - // Use buffered logging to avoid spamming the logs in case this is triggered for - // many buckets simultaneously. - LOGBP(error, "Inserted empty bucket %s into database.\n%s", - id.toString().c_str(), vespalib::getStackTrace(2).c_str()); -} - -} - -template <typename EntryType> -void MapBucketDatabase::update_internal(EntryType&& new_entry) { - assert(new_entry.valid()); - if (new_entry->getNodeCount() == 0) { - log_empty_bucket_insertion(new_entry.getBucketId()); - } - Entry* found = find(0, 0, new_entry.getBucketId(), true); - assert(found); - *found = std::forward<EntryType>(new_entry); -} - -void -MapBucketDatabase::update(const Entry& newEntry) -{ - update_internal(newEntry); -} - -void -MapBucketDatabase::findParents(int index, - uint8_t bitCount, - const document::BucketId& bid, - std::vector<Entry>& entries) const -{ - if (index == -1) { - return; - } - - const E& e = _db[index]; - if (e.value != -1) { - entries.push_back(_values[e.value]); - } - - if (bitCount >= bid.getUsedBits()) { - return; - } - - if (bid.getBit(bitCount) == 0) { - findParents(e.e_0, bitCount + 1, bid, entries); - } else { - findParents(e.e_1, bitCount + 1, bid, entries); - } -} - - -void -MapBucketDatabase::getParents(const document::BucketId& childBucket, - std::vector<Entry>& entries) const -{ - findParents(0, 0, childBucket, entries); -} - -void -MapBucketDatabase::findAll(int index, - uint8_t bitCount, - const document::BucketId& bid, - std::vector<Entry>& entries) const -{ - if (index == -1) { - return; - } - - const E& e = _db[index]; - if (e.value != -1) { - entries.push_back(_values[e.value]); - } - - if (bitCount >= bid.getUsedBits()) { - findAll(e.e_0, bitCount + 1, bid, entries); - findAll(e.e_1, bitCount + 1, bid, entries); - } else { - if (bid.getBit(bitCount) == 0) { - findAll(e.e_0, bitCount + 1, bid, entries); - } else { - findAll(e.e_1, bitCount + 1, bid, entries); - } - } -} - -void -MapBucketDatabase::getAll(const document::BucketId& bucket, - std::vector<Entry>& entries) const -{ - findAll(0, 0, bucket, entries); -} - -/** - * Any child bucket under a bucket held in an inner node will be ordered after - * (i.e. be greater than) the inner node bucket. This is because in bucket key - * order these have the same bit prefix but are guaranteed to have a suffix that - * make them greater. From our bucket ordering spec, a bucket with 5 bits of - * 00000 is greater than a bucket of 3 bits of 000 because the suffix logically - * takes into account the number of used bucket bits (meaning the actual - * values are more akin to 000000000:5 and 00000000:3). When traversing the bit - * tree, we mirror this behavior since all child nodes by definition have a - * higher used bit value from their depth in the tree. - */ -int -MapBucketDatabase::findFirstInOrderNodeInclusive(int index) const -{ - if (index == -1) { - return -1; - } - - int follow = index; - while (true) { - const E& e = _db[follow]; - if (e.value != -1) { - return follow; - } - // In-order 0 bits sort before 1 bits so we follow the 0 branch if - // at all possible. It is illegal for a branch to exist without there - // existing a leaf somewhere underneath it, so we're destined to hit - // something if it exists. - follow = (e.e_0 != -1 ? e.e_0 : e.e_1); - if (follow == -1) { - return -1; - } - } -} - -/** - * Follow the bit tree as far as we can based on upper bound `value`. To get a - * bucket with an ID greater than `value` we must try to follow the bit tree - * as far down as possible, taking the branches that correspond to our input - * value: - * 1) If input value has a 0 bit in the `depth` position but no such branch - * exists at the current node we look in its 1 branch (if one exists), - * returning the first in-order child. - * 2) If we've reached a node that equals the input value (current depth - * equals used bits), look for the first in-order child under the node - * in question. - * 3) Otherwise, keep recursing down the same bit prefix subtree. - */ -int -MapBucketDatabase::upperBoundImpl(int index, - uint8_t depth, - const document::BucketId& value) const -{ - if (index == -1) { - return -1; // Branch with no children; bail out and up. - } - - const E& e = _db[index]; - if (depth < value.getUsedBits()) { - if (value.getBit(depth) == 0) { - int candidate = upperBoundImpl(e.e_0, depth + 1, value); - if (candidate != -1) { - return candidate; - } - // No choice but to try to follow 1-branch. - return findFirstInOrderNodeInclusive(e.e_1); - } else { - return upperBoundImpl(e.e_1, depth + 1, value); - } - } else { - // We've hit a node whose bucket ID corresponds exactly to that given - // in `value`. Find the first in-order child node, if one exists. - // Please see findFirstInOrderNodeInclusive() comments for an - // explanation of why this satisfies the upper bound ordering - // requirements. - // Due to Funky Business(tm) inside BucketId, asking for getBit beyond - // usedBits returns potentially undefined values, so we have to treat - // this case by itself. - int candidate = findFirstInOrderNodeInclusive(e.e_0); - if (candidate == -1) { - candidate = findFirstInOrderNodeInclusive(e.e_1); - } - return candidate; - } -} - -BucketDatabase::Entry -MapBucketDatabase::upperBound(const document::BucketId& value) const -{ - int index = upperBoundImpl(0, 0, value); - if (index != -1) { - assert(_db[index].value != -1); - return _values[_db[index].value]; - } - return Entry::createInvalid(); -} - -namespace { - -inline BucketDatabase::ConstEntryRef -to_entry_ref(const BucketDatabase::Entry& e) { - return BucketDatabase::ConstEntryRef( - e.getBucketId(), - ConstBucketInfoRef(e->getLastGarbageCollectionTime(), e->getRawNodes())); -} - -} - -bool -MapBucketDatabase::forEach(int index, - EntryProcessor& processor, - uint8_t bitCount, - const document::BucketId& lowerBound, - bool& process) const -{ - if (index == -1) { - return true; - } - - const E& e = _db[index]; - if (e.value != -1 && process - && !processor.process(to_entry_ref(_values[e.value]))) - { - return false; - } - - // We have followed the bucket to where we want to start, - // start processing. - if (!process && bitCount >= lowerBound.getUsedBits()) { - process = true; - } - - if (process || lowerBound.getBit(bitCount) == 0) { - if (!forEach(e.e_0, processor, bitCount + 1, lowerBound, process)) { - return false; - } - } - - if (process || lowerBound.getBit(bitCount) != 0) { - if (!forEach(e.e_1, processor, bitCount + 1, lowerBound, process)) { - return false; - } - } - - return true; -} - -void -MapBucketDatabase::forEach(EntryProcessor& processor, - const document::BucketId& after) const -{ - bool process = false; - forEach(0, processor, 0, after, process); -} - -struct MapDbMerger final : BucketDatabase::Merger { - MapBucketDatabase& _db; - BucketDatabase::Entry& _current_entry; - std::vector<BucketDatabase::Entry>& _to_insert; - - MapDbMerger(MapBucketDatabase& db, - BucketDatabase::Entry& current_entry, - std::vector<BucketDatabase::Entry>& to_insert) - : _db(db), - _current_entry(current_entry), - _to_insert(to_insert) - {} - - uint64_t bucket_key() const noexcept override { - return _current_entry.getBucketId().toKey(); - } - document::BucketId bucket_id() const noexcept override { - return _current_entry.getBucketId(); - } - BucketDatabase::Entry& current_entry() override { - return _current_entry; - } - void insert_before_current([[maybe_unused]] const document::BucketId& bucket_id, - const BucketDatabase::Entry& e) override { - _to_insert.emplace_back(e); // TODO movable - } -}; - -struct MapDbTrailingInserter final : BucketDatabase::TrailingInserter { - MapBucketDatabase& _db; - explicit MapDbTrailingInserter(MapBucketDatabase& db) : _db(db) {} - - void insert_at_end([[maybe_unused]] const document::BucketId& bucket_id, - const BucketDatabase::Entry& e) override { - _db.update(e); - } -}; - -void MapBucketDatabase::merge_internal(int index, - MergingProcessor& processor, - std::vector<Entry>& to_insert, - std::vector<document::BucketId>& to_remove) -{ - if (index == -1) { - return; - } - E& e = _db[index]; - if (e.value != -1) { - Entry& entry = _values[e.value]; - MapDbMerger merger(*this, entry, to_insert); - auto result = processor.merge(merger); - if (result == MergingProcessor::Result::KeepUnchanged) { - // No-op - } else if (result == MergingProcessor::Result::Update) { - // Also no-op since it's all in-place - } else if (result == MergingProcessor::Result::Skip) { - to_remove.emplace_back(entry.getBucketId()); - } - } - merge_internal(e.e_0, processor, to_insert, to_remove); - merge_internal(e.e_1, processor, to_insert, to_remove); -} - -void MapBucketDatabase::merge(MergingProcessor& processor) { - std::vector<document::BucketId> to_remove; - std::vector<Entry> to_insert; - merge_internal(0, processor, to_insert, to_remove); - for (const auto& bucket : to_remove) { - remove(bucket); - } - for (auto& e : to_insert) { - update_internal(std::move(e)); - } - MapDbTrailingInserter inserter(*this); - processor.insert_remaining_at_end(inserter); -} - -void -MapBucketDatabase::clear() -{ - _db.clear(); - _values.clear(); - _free.clear(); - _freeValues.clear(); - allocate(); -} - -uint8_t -MapBucketDatabase::getHighestSplitBit(int index, - uint8_t bitCount, - const document::BucketId& bid, - uint8_t minCount) -{ - if (index == -1) { - return minCount; - } - - E& e = _db[index]; - if (bitCount == bid.getUsedBits()) { - return minCount; - } - - if (bid.getBit(bitCount) == 0) { - if (e.e_0 != -1) { - minCount = getHighestSplitBit(e.e_0, - bitCount + 1, - bid, - minCount); - } - - if (e.e_1 != -1) { - return std::max((int)minCount, bitCount + 1); - } - } else { - if (e.e_1 != -1) { - minCount = getHighestSplitBit(e.e_1, - bitCount + 1, - bid, - minCount); - } - - if (e.e_0 != -1) { - return std::max((int)minCount, bitCount + 1); - } - } - - return minCount; - -} - -document::BucketId -MapBucketDatabase::getAppropriateBucket( - uint16_t minBits, - const document::BucketId& bid) -{ - return document::BucketId(getHighestSplitBit(0, 0, bid, minBits), - bid.getRawId()); -} - -uint32_t -MapBucketDatabase::childCountImpl(int index, - uint8_t bitCount, - const document::BucketId& b) const -{ - if (index == -1) { - // A non-existing node cannot have any subtrees (obviously). - return 0; - } - const E& e(_db[index]); - if (bitCount == b.getUsedBits()) { - // If a child has a valid index, it counts as a subtree. - return ((e.e_0 != -1) + (e.e_1 != -1)); - } - if (b.getBit(bitCount) == 0) { - return childCountImpl(e.e_0, bitCount + 1, b); - } else { - return childCountImpl(e.e_1, bitCount + 1, b); - } -} - -uint32_t -MapBucketDatabase::childCount(const document::BucketId& b) const -{ - return childCountImpl(0, 0, b); -} - - -namespace { - struct Writer : public BucketDatabase::EntryProcessor { - std::ostream& _ost; - explicit Writer(std::ostream& ost) : _ost(ost) {} - bool process(const BucketDatabase::ConstEntryRef& e) override { - _ost << e.toString() << "\n"; - return true; - } - }; -} - -void -MapBucketDatabase::print(std::ostream& out, bool verbose, - const std::string& indent) const -{ - out << "MapBucketDatabase("; - (void) indent; - if (verbose) { - Writer writer(out); - forEach(writer); - } else { - out << "Size(" << size() << ") Nodes(" - << (_db.size() - _free.size() - 1) << ")"; - } - out << ')'; -} - -std::unique_ptr<bucketdb::ReadGuard<BucketDatabase::Entry>> MapBucketDatabase::acquire_read_guard() const { - return std::make_unique<ReadGuardImpl>(*this); -} - -void MapBucketDatabase::ReadGuardImpl::find_parents_and_self(const document::BucketId& bucket, - std::vector<Entry>& entries) const -{ - _db->getParents(bucket, entries); -} - -namespace { - -template <typename T> -size_t allocated_by_vec(const T& vec) noexcept { - return (vec.capacity() * sizeof(typename T::value_type)); -} - -template <typename T> -size_t used_by_vec(const T& vec) noexcept { - return (vec.size() * sizeof(typename T::value_type)); -} - -} - -vespalib::MemoryUsage MapBucketDatabase::memory_usage() const noexcept { - // We don't have a concept of hold lists here, nor do we know the exact size of the - // entries on our free list (these wrap a secondary replica vector allocation). - // So we fudge the numbers a bit, returning a lower bound approximation only. - // That's OK since this is a legacy database that's on the way out anyway. - vespalib::MemoryUsage mem_usage; - mem_usage.incAllocatedBytes(allocated_by_vec(_values) + allocated_by_vec(_db)); - mem_usage.incUsedBytes(used_by_vec(_values) + used_by_vec(_db)); - mem_usage.incDeadBytes(allocated_by_vec(_free) + allocated_by_vec(_freeValues)); - return mem_usage; -} - -} // storage diff --git a/storage/src/vespa/storage/bucketdb/mapbucketdatabase.h b/storage/src/vespa/storage/bucketdb/mapbucketdatabase.h deleted file mode 100644 index e8d5688068f..00000000000 --- a/storage/src/vespa/storage/bucketdb/mapbucketdatabase.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include "bucketdatabase.h" -#include <map> - -namespace storage { - -class MapBucketDatabase : public BucketDatabase -{ -public: - MapBucketDatabase(); - ~MapBucketDatabase(); - - Entry get(const document::BucketId& bucket) const override; - void remove(const document::BucketId& bucket) override; - void getParents(const document::BucketId& childBucket, std::vector<Entry>& entries) const override; - void getAll(const document::BucketId& bucket, std::vector<Entry>& entries) const override; - void update(const Entry& newEntry) override; - void forEach(EntryProcessor&, const document::BucketId& after = document::BucketId()) const override; - uint64_t size() const override { return _values.size() - _freeValues.size(); }; - void clear() override; - - uint32_t childCount(const document::BucketId&) const override; - Entry upperBound(const document::BucketId& value) const override; - - void merge(MergingProcessor&) override; - - document::BucketId getAppropriateBucket(uint16_t minBits, const document::BucketId& bid) override; - void print(std::ostream& out, bool verbose, const std::string& indent) const override; - - std::unique_ptr<bucketdb::ReadGuard<Entry>> acquire_read_guard() const override; - vespalib::MemoryUsage memory_usage() const noexcept override; -private: - struct E { - E() : value(-1), e_0(-1), e_1(-1) {}; - ~E(); - - bool empty() { - return (value == -1 && e_0 == -1 && e_1 == -1); - }; - - int value; - int e_0; - int e_1; - }; - - template <typename EntryType> - void update_internal(EntryType&& new_entry); - - BucketDatabase::Entry* find(int idx, uint8_t bitCount, const document::BucketId& bid, bool create); - bool remove(int index, uint8_t bitCount, const document::BucketId& bId); - int findFirstInOrderNodeInclusive(int index) const; - int upperBoundImpl(int index, uint8_t depth, const document::BucketId& value) const; - - bool forEach(int index, EntryProcessor& processor, uint8_t bitCount, - const document::BucketId& lowerBound, bool& process) const; - - void merge_internal(int index, MergingProcessor& processor, - std::vector<Entry>& to_insert, - std::vector<document::BucketId>& to_remove); - - void findParents(int index, uint8_t bitCount, const document::BucketId& bid, std::vector<Entry>& entries) const; - void findAll(int index, uint8_t bitCount, const document::BucketId& bid, std::vector<Entry>& entries) const; - uint8_t getHighestSplitBit(int index, uint8_t bitCount, const document::BucketId& bid, uint8_t minCount); - uint32_t childCountImpl(int index, uint8_t bitCount, const document::BucketId& b) const; - - // NOT thread-safe for concurrent reads! - class ReadGuardImpl final : public bucketdb::ReadGuard<Entry> { - const MapBucketDatabase* _db; - public: - explicit ReadGuardImpl(const MapBucketDatabase& db) : _db(&db) {} - ~ReadGuardImpl() override = default; - - void find_parents_and_self(const document::BucketId& bucket, - std::vector<Entry>& entries) const override; - uint64_t generation() const noexcept override { return 0; } - }; - - uint32_t allocate(); - uint32_t allocateValue(const document::BucketId& bid); - - std::vector<E> _db; - std::vector<uint32_t> _free; - - std::vector<BucketDatabase::Entry> _values; - std::vector<uint32_t> _freeValues; -}; - -} diff --git a/storage/src/vespa/storage/distributor/distributor.cpp b/storage/src/vespa/storage/distributor/distributor.cpp index 5080b16c727..c74d4135556 100644 --- a/storage/src/vespa/storage/distributor/distributor.cpp +++ b/storage/src/vespa/storage/distributor/distributor.cpp @@ -61,7 +61,6 @@ Distributor::Distributor(DistributorComponentRegister& compReg, framework::TickingThreadPool& threadPool, DoneInitializeHandler& doneInitHandler, bool manageActiveBucketCopies, - bool use_btree_database, HostInfo& hostInfoReporterRegistrar, ChainedMessageSender* messageSender) : StorageLink("distributor"), @@ -70,8 +69,8 @@ Distributor::Distributor(DistributorComponentRegister& compReg, _clusterStateBundle(lib::ClusterState()), _compReg(compReg), _component(compReg, "distributor"), - _bucketSpaceRepo(std::make_unique<DistributorBucketSpaceRepo>(use_btree_database)), - _readOnlyBucketSpaceRepo(std::make_unique<DistributorBucketSpaceRepo>(use_btree_database)), + _bucketSpaceRepo(std::make_unique<DistributorBucketSpaceRepo>()), + _readOnlyBucketSpaceRepo(std::make_unique<DistributorBucketSpaceRepo>()), _metrics(new DistributorMetricSet(_component.getLoadTypes()->getMetricLoadTypes())), _operationOwner(*this, _component.getClock()), _maintenanceOperationOwner(*this, _component.getClock()), @@ -106,8 +105,7 @@ Distributor::Distributor(DistributorComponentRegister& compReg, _db_memory_sample_interval(30s), _last_db_memory_sample_time_point(), _inhibited_maintenance_tick_count(0), - _must_send_updated_host_info(false), - _use_btree_database(use_btree_database) + _must_send_updated_host_info(false) { _component.registerMetric(*_metrics); _component.registerMetricUpdateHook(_metricUpdateHook, @@ -886,9 +884,8 @@ Distributor::enableNextConfig() _ownershipSafeTimeCalc->setMaxClusterClockSkew(getConfig().getMaxClusterClockSkew()); _pendingMessageTracker.setNodeBusyDuration(getConfig().getInhibitMergesOnBusyNodeDuration()); _bucketDBUpdater.set_stale_reads_enabled(getConfig().allowStaleReadsDuringClusterStateTransitions()); - // Concurrent reads are only safe if the B-tree DB implementation is used. _externalOperationHandler.set_concurrent_gets_enabled( - _use_btree_database && getConfig().allowStaleReadsDuringClusterStateTransitions()); + getConfig().allowStaleReadsDuringClusterStateTransitions()); _externalOperationHandler.set_use_weak_internal_read_consistency_for_gets( getConfig().use_weak_internal_read_consistency_for_client_gets()); } diff --git a/storage/src/vespa/storage/distributor/distributor.h b/storage/src/vespa/storage/distributor/distributor.h index 36d399b0a9f..84e195fdff2 100644 --- a/storage/src/vespa/storage/distributor/distributor.h +++ b/storage/src/vespa/storage/distributor/distributor.h @@ -51,7 +51,6 @@ public: framework::TickingThreadPool&, DoneInitializeHandler&, bool manageActiveBucketCopies, - bool use_btree_database, HostInfo& hostInfoReporterRegistrar, ChainedMessageSender* = nullptr); @@ -341,7 +340,6 @@ private: std::chrono::steady_clock::time_point _last_db_memory_sample_time_point; size_t _inhibited_maintenance_tick_count; bool _must_send_updated_host_info; - const bool _use_btree_database; }; } // distributor diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space.cpp b/storage/src/vespa/storage/distributor/distributor_bucket_space.cpp index 3f7dbda62d9..7b7970228e7 100644 --- a/storage/src/vespa/storage/distributor/distributor_bucket_space.cpp +++ b/storage/src/vespa/storage/distributor/distributor_bucket_space.cpp @@ -1,26 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "distributor_bucket_space.h" -#include <vespa/storage/bucketdb/mapbucketdatabase.h> #include <vespa/storage/bucketdb/btree_bucket_database.h> #include <vespa/vdslib/state/clusterstate.h> #include <vespa/vdslib/distribution/distribution.h> namespace storage::distributor { -namespace { - -std::unique_ptr<BucketDatabase> make_default_db_impl(bool use_btree_db) { - if (use_btree_db) { - return std::make_unique<BTreeBucketDatabase>(); - } - return std::make_unique<MapBucketDatabase>(); -} - -} - -DistributorBucketSpace::DistributorBucketSpace(bool use_btree_db) - : _bucketDatabase(make_default_db_impl(use_btree_db)), +DistributorBucketSpace::DistributorBucketSpace() + : _bucketDatabase(std::make_unique<BTreeBucketDatabase>()), _clusterState(), _distribution() { diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space.h b/storage/src/vespa/storage/distributor/distributor_bucket_space.h index 8fbb99dfe89..c137414ecfb 100644 --- a/storage/src/vespa/storage/distributor/distributor_bucket_space.h +++ b/storage/src/vespa/storage/distributor/distributor_bucket_space.h @@ -30,7 +30,7 @@ class DistributorBucketSpace { std::shared_ptr<const lib::ClusterState> _clusterState; std::shared_ptr<const lib::Distribution> _distribution; public: - explicit DistributorBucketSpace(bool use_btree_db); + explicit DistributorBucketSpace(); ~DistributorBucketSpace(); DistributorBucketSpace(const DistributorBucketSpace&) = delete; diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp b/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp index 54287d32666..744c54676ae 100644 --- a/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp +++ b/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp @@ -13,11 +13,11 @@ using document::BucketSpace; namespace storage::distributor { -DistributorBucketSpaceRepo::DistributorBucketSpaceRepo(bool use_btree_db) +DistributorBucketSpaceRepo::DistributorBucketSpaceRepo() : _map() { - add(document::FixedBucketSpaces::default_space(), std::make_unique<DistributorBucketSpace>(use_btree_db)); - add(document::FixedBucketSpaces::global_space(), std::make_unique<DistributorBucketSpace>(use_btree_db)); + add(document::FixedBucketSpaces::default_space(), std::make_unique<DistributorBucketSpace>()); + add(document::FixedBucketSpaces::global_space(), std::make_unique<DistributorBucketSpace>()); } DistributorBucketSpaceRepo::~DistributorBucketSpaceRepo() = default; diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h b/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h index bc42ae8bb3a..ee36842969a 100644 --- a/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h +++ b/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h @@ -19,7 +19,7 @@ private: BucketSpaceMap _map; public: - explicit DistributorBucketSpaceRepo(bool use_btree_db); // TODO remove param once B-tree is default + DistributorBucketSpaceRepo(); ~DistributorBucketSpaceRepo(); DistributorBucketSpaceRepo(const DistributorBucketSpaceRepo&&) = delete; diff --git a/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h b/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h index c2a92dd2c69..61fba7f9921 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h +++ b/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h @@ -8,7 +8,6 @@ #pragma once #include "storagecomponentregisterimpl.h" -#include <vespa/storage/bucketdb/mapbucketdatabase.h> #include <vespa/storage/common/distributorcomponent.h> #include <vespa/storage/common/nodestateupdater.h> @@ -34,7 +33,7 @@ public: typedef std::unique_ptr<DistributorComponentRegisterImpl> UP; DistributorComponentRegisterImpl(); - ~DistributorComponentRegisterImpl(); + ~DistributorComponentRegisterImpl() override; void registerDistributorComponent(DistributorManagedComponent&) override; void setTimeCalculator(UniqueTimeCalculator& calc); diff --git a/storage/src/vespa/storage/storageserver/distributornode.cpp b/storage/src/vespa/storage/storageserver/distributornode.cpp index 20b5dd641f7..1cd1477e769 100644 --- a/storage/src/vespa/storage/storageserver/distributornode.cpp +++ b/storage/src/vespa/storage/storageserver/distributornode.cpp @@ -19,7 +19,6 @@ DistributorNode::DistributorNode( DistributorNodeContext& context, ApplicationGenerationFetcher& generationFetcher, NeedActiveState activeState, - bool use_btree_database, StorageLink::UP communicationManager) : StorageNode(configUri, context, generationFetcher, std::unique_ptr<HostInfo>(new HostInfo()), @@ -30,7 +29,6 @@ DistributorNode::DistributorNode( _lastUniqueTimestampRequested(0), _uniqueTimestampCounter(0), _manageActiveBucketCopies(activeState == NEED_ACTIVE_BUCKET_STATES_SET), - _use_btree_database(use_btree_database), _retrievedCommunicationManager(std::move(communicationManager)) { try{ @@ -110,7 +108,6 @@ DistributorNode::createChain() new storage::distributor::Distributor( dcr, *_threadPool, getDoneInitializeHandler(), _manageActiveBucketCopies, - _use_btree_database, stateManager->getHostInfo()))); chain->push_back(StorageLink::UP(stateManager.release())); diff --git a/storage/src/vespa/storage/storageserver/distributornode.h b/storage/src/vespa/storage/storageserver/distributornode.h index 3a81e31fc56..4db8876dc24 100644 --- a/storage/src/vespa/storage/storageserver/distributornode.h +++ b/storage/src/vespa/storage/storageserver/distributornode.h @@ -24,7 +24,6 @@ class DistributorNode uint64_t _lastUniqueTimestampRequested; uint32_t _uniqueTimestampCounter; bool _manageActiveBucketCopies; - bool _use_btree_database; std::unique_ptr<StorageLink> _retrievedCommunicationManager; public: @@ -39,7 +38,6 @@ public: DistributorNodeContext&, ApplicationGenerationFetcher& generationFetcher, NeedActiveState, - bool use_btree_database, std::unique_ptr<StorageLink> communicationManager); ~DistributorNode() override; diff --git a/storage/src/vespa/storage/tools/generatedistributionbits.cpp b/storage/src/vespa/storage/tools/generatedistributionbits.cpp index 98c5e56b90c..0885483f674 100644 --- a/storage/src/vespa/storage/tools/generatedistributionbits.cpp +++ b/storage/src/vespa/storage/tools/generatedistributionbits.cpp @@ -128,7 +128,7 @@ int main(int argc, char** argv) { std::cerr << e.getMessage() << "\n\n"; o.writeSyntaxPage(std::cerr); std::cerr << "\n"; - exit(1); + return 1; } o.finalize(); if (o.printHtml) { std::cout << "<b>"; } diff --git a/storageapi/src/vespa/storageapi/app/getbucketid.cpp b/storageapi/src/vespa/storageapi/app/getbucketid.cpp index 25c2fd2fc37..4f6552ac3f0 100644 --- a/storageapi/src/vespa/storageapi/app/getbucketid.cpp +++ b/storageapi/src/vespa/storageapi/app/getbucketid.cpp @@ -7,7 +7,7 @@ int main(int argc, char** argv) { if (argc != 2) { std::cerr << "Usage: getbucketid <documentid>\n"; - exit(1); + return 1; } document::BucketIdFactory factory; document::BucketId id = factory.getBucketId(document::DocumentId(argv[1])); diff --git a/storageserver/src/apps/storaged/storage.cpp b/storageserver/src/apps/storaged/storage.cpp index e789fd68ecb..903c61875ed 100644 --- a/storageserver/src/apps/storaged/storage.cpp +++ b/storageserver/src/apps/storaged/storage.cpp @@ -21,6 +21,7 @@ #include <vespa/fastos/app.h> #include <iostream> #include <csignal> +#include <cstdlib> #include <vespa/log/log.h> LOG_SETUP("vds.application"); @@ -109,11 +110,11 @@ bool StorageApp::Init() } catch (vespalib::InvalidCommandLineArgumentsException& e) { std::cerr << e.getMessage() << "\n\n"; writeSyntaxPage(std::cerr); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } if (_showSyntax) { writeSyntaxPage(std::cerr); - exit(0); + std::_Exit(0); } return true; } diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp index 938ca63b50f..d9972116559 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp @@ -11,8 +11,7 @@ namespace storage { DistributorProcess::DistributorProcess(const config::ConfigUri & configUri) : Process(configUri), - _activeFlag(DistributorNode::NO_NEED_FOR_ACTIVE_STATES), - _use_btree_database(false) + _activeFlag(DistributorNode::NO_NEED_FOR_ACTIVE_STATES) { } @@ -39,8 +38,6 @@ DistributorProcess::setupConfig(milliseconds subscribeTimeout) if (stor_config->persistenceProvider.type != StorServerConfig::PersistenceProvider::Type::STORAGE) { _activeFlag = DistributorNode::NEED_ACTIVE_BUCKET_STATES_SET; } - auto dist_config = config::ConfigGetter<StorDistributormanagerConfig>::getConfig(_configUri.getConfigId(), _configUri.getContext(), subscribeTimeout); - _use_btree_database = dist_config->useBtreeDatabase; _distributorConfigHandler = _configSubscriber.subscribe<StorDistributormanagerConfig>(_configUri.getConfigId(), subscribeTimeout); _visitDispatcherConfigHandler = _configSubscriber.subscribe<StorVisitordispatcherConfig>(_configUri.getConfigId(), subscribeTimeout); Process::setupConfig(subscribeTimeout); @@ -76,7 +73,7 @@ DistributorProcess::configUpdated() void DistributorProcess::createNode() { - _node.reset(new DistributorNode(_configUri, _context, *this, _activeFlag, _use_btree_database, StorageLink::UP())); + _node.reset(new DistributorNode(_configUri, _context, *this, _activeFlag, StorageLink::UP())); _node->handleConfigChange(*_distributorConfigHandler->getConfig()); _node->handleConfigChange(*_visitDispatcherConfigHandler->getConfig()); } diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.h b/storageserver/src/vespa/storageserver/app/distributorprocess.h index e416f285268..4a2289e6151 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.h +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.h @@ -15,7 +15,6 @@ namespace storage { class DistributorProcess final : public Process { DistributorNodeContext _context; DistributorNode::NeedActiveState _activeFlag; - bool _use_btree_database; DistributorNode::UP _node; config::ConfigHandle<vespa::config::content::core::StorDistributormanagerConfig>::UP _distributorConfigHandler; diff --git a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp index 1b8f31f0d03..082aa83c3da 100644 --- a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp +++ b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp @@ -15,6 +15,7 @@ #include <sstream> #include <iostream> #include <thread> +#include <cstdlib> #include <sys/time.h> #include <vespa/log/log.h> @@ -128,7 +129,7 @@ struct Options : public vespalib::ProgramOptions { _clusterName = _cluster.getName(); } catch (const vespaclient::ClusterList::ClusterNotFoundException& e) { std::cerr << e.getMessage() << "\n"; - exit(1); + std::_Exit(1); } return true; } diff --git a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp index 3041627b2d0..0141e32e435 100644 --- a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp +++ b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp @@ -310,13 +310,13 @@ int main(int argc, char *argv[]) } else { std::vector<pthread_t> threads(numThreads); for (size_t j(0); j < numThreads; j++) { - pthread_create(&threads[j], NULL, (VFUNC)runBenchMark, &indirectSlotVector); + pthread_create(&threads[j], NULL, (VFUNC)runBenchMark, &indirectSlotVector); } for (size_t j(0); j < numThreads; j++) { pthread_join(threads[j], NULL); } } - break; + break; default: printf("'m' = %s\n", description[type]); printf("'M' = %s\n", description[type]); @@ -327,11 +327,10 @@ int main(int argc, char *argv[]) printf("'g' = %s\n", description[type]); printf("'G' = %s\n", description[type]); printf("'J' = %s\n", description[type]); - printf("Unspecified type %c. Running map benchmark\n", type); - exit(1); - break; + printf("Unspecified type %c.\n", type); + return 1; } } printf("Running test '%c' = %s, result = %ld unique values\n", type, description[type], uniq); + return 0; } - diff --git a/vespalog/src/logctl/logctl.cpp b/vespalog/src/logctl/logctl.cpp index 950b7929a50..14137a79687 100644 --- a/vespalog/src/logctl/logctl.cpp +++ b/vespalog/src/logctl/logctl.cpp @@ -132,7 +132,7 @@ main(int argc, char **argv) break; case 'h': usage(argv[0]); - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } } @@ -154,17 +154,17 @@ main(int argc, char **argv) services = findAllFiles(dir); if (doOnlyFile) { fprintf(stderr, "-f and -a options cannot be used at the same time\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } // No log control files exist if (services.empty()) { - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } } else { if (optind >= argc) { usage(argv[0]); fprintf(stderr, "ERROR: Missing service argument!\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } char *service = strdup(argv[optind]); ++optind; @@ -195,7 +195,7 @@ main(int argc, char **argv) if (argc > optind) { usage(argv[0]); fprintf(stderr, "ERROR: Too many arguments!\n\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } bool hadFailure = false; @@ -221,12 +221,12 @@ main(int argc, char **argv) hadFailure = true; } } - if (hadFailure) exit(EXIT_FAILURE); + if (hadFailure) return EXIT_FAILURE; if (! hadSuccess) { fprintf(stderr, "no logcontrol files updates\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } static void diff --git a/vespalog/src/logger/logger.cpp b/vespalog/src/logger/logger.cpp index 80a2f4c0aa7..0b33f251797 100644 --- a/vespalog/src/logger/logger.cpp +++ b/vespalog/src/logger/logger.cpp @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) default: fprintf(stderr, "Usage: foo | %s [-s service] [-c component]" "[-l level] [-p pid]\n", argv[0]); - exit(ch != 'h'); + return (ch == 'h') ? EXIT_SUCCESS : EXIT_FAILURE; } } diff --git a/vespalog/src/logger/logreplay.c b/vespalog/src/logger/logreplay.c index 70a1b9a08a9..7a920a916a4 100644 --- a/vespalog/src/logger/logreplay.c +++ b/vespalog/src/logger/logreplay.c @@ -19,7 +19,7 @@ main(int argc, char **argv) "Replays a vespa log file with the same timing delta between each log message.\n" "Reprints the log messages without timestamps.\n\n", argv[0]); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } while (fgets(line, sizeof line, stdin)) { @@ -54,5 +54,5 @@ main(int argc, char **argv) fwrite(s, strlen(s), 1, stdout); fflush(stdout); } - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } diff --git a/vespalog/src/logger/runserver.cpp b/vespalog/src/logger/runserver.cpp index e58565f78b9..f1754e84272 100644 --- a/vespalog/src/logger/runserver.cpp +++ b/vespalog/src/logger/runserver.cpp @@ -102,7 +102,7 @@ PidFile::writePid() if (didtruncate != 0) { fprintf(stderr, "could not truncate pid file %s: %s\n", _pidfile, strerror(errno)); - exit(1); + std::_Exit(1); } char buf[100]; sprintf(buf, "%d\n", getpid()); @@ -111,7 +111,7 @@ PidFile::writePid() if (didw != l) { fprintf(stderr, "could not write pid to %s: %s\n", _pidfile, strerror(errno)); - exit(1); + std::_Exit(1); } LOG(debug, "wrote '%s' to %s (fd %d)", buf, _pidfile, _fd); } @@ -168,7 +168,7 @@ int loop(const char *svc, char * const * run) if (pipe(pstdout) < 0 || pipe(pstderr) < 0) { LOG(error, "pipe: %s", strerror(errno)); - exit(1); + std::_Exit(1); } LOG(debug, "stdout pipe %d <- %d; stderr pipe %d <- %d", pstdout[0], pstdout[1], @@ -188,11 +188,11 @@ int loop(const char *svc, char * const * run) close(pstderr[1]); execvp(run[0], run); LOG(error, "exec %s: %s", run[0], strerror(errno)); - exit(1); + std::_Exit(1); } if (child < 0) { LOG(error, "fork(): %s", strerror(errno)); - exit(1); + std::_Exit(1); } // I am the parent process @@ -325,13 +325,13 @@ int loop(const char *svc, char * const * run) return WEXITSTATUS(wstat); } -void usage(char *prog, int es) +int usage(char *prog, int es) { fprintf(stderr, "Usage: %s\n" " [-s service] [-r restartinterval] [-p pidfile]" " program [args ...]\n" "or: [-p pidfile] [-k killcmd] -S\n", prog); - exit(es); + return es; } int main(int argc, char *argv[]) @@ -363,7 +363,7 @@ int main(int argc, char *argv[]) killcmd = optarg; break; default: - usage(argv[0], ch != 'h'); + return usage(argv[0], ch != 'h'); } } @@ -374,7 +374,7 @@ int main(int argc, char *argv[]) } if (chdir(envROOT) != 0) { fprintf(stderr, "Cannot chdir to %s: %s\n", envROOT, strerror(errno)); - exit(1); + return 1; } PidFile mypf(pidfile); @@ -393,7 +393,7 @@ int main(int argc, char *argv[]) if (killpg(pid, SIGTERM) != 0) { fprintf(stderr, "could not signal %d: %s\n", pid, strerror(errno)); - exit(1); + return 1; } } fprintf(stdout, "Waiting for exit (up to 60 seconds)\n"); @@ -421,16 +421,16 @@ int main(int argc, char *argv[]) service, pidfile); } mypf.cleanUp(); - exit(0); + return 0; } if (optind >= argc || killcmd != NULL) { - usage(argv[0], 1); + return usage(argv[0], 1); } if (mypf.anotherRunning()) { fprintf(stderr, "runserver already running with pid %d\n", mypf.readPid()); - exit(0); + return 0; } if (!mypf.writeOpen()) { @@ -443,17 +443,17 @@ int main(int argc, char *argv[]) close(0); if (open("/dev/null", O_RDONLY) != 0) { perror("open /dev/null for reading failed"); - exit(1); + std::_Exit(1); } close(1); if (open("/dev/null", O_WRONLY) != 1) { perror("open /dev/null for writing failed"); - exit(1); + std::_Exit(1); } dup2(1, 2); if (setsid() < 0) { perror("setsid"); - exit(1); + std::_Exit(1); } struct sigaction act; struct sigaction oact; @@ -482,15 +482,14 @@ int main(int argc, char *argv[]) } while (!gotstopsig && restart > 0); } catch (MsgException& ex) { LOG(error, "exception: '%s'", ex.what()); - exit(1); + return 1; } if (restart > 0) { LOG(debug, "final exit status: %d", stat); } mypf.cleanUp(); - exit(stat); + return stat; } - if (rsp < 0) { perror("fork"); return 1; diff --git a/vespalog/src/test/bufferedlogskiptest.cpp b/vespalog/src/test/bufferedlogskiptest.cpp index 21a3044e676..55815480e97 100644 --- a/vespalog/src/test/bufferedlogskiptest.cpp +++ b/vespalog/src/test/bufferedlogskiptest.cpp @@ -5,6 +5,7 @@ #include <fstream> #include <iostream> #include <unistd.h> +#include <cstdlib> LOG_SETUP("bufferedlogskiptest"); @@ -53,10 +54,9 @@ void testSkipBufferOnDebug(const std::string& file, uint64_t & timer) [[maybe_unused]] int system_result = system(("diff -u " + file + " bufferedlogskiptest.skipped.log").c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); - } void reset(uint64_t & timer) { @@ -71,7 +71,7 @@ main(int argc, char **argv) { if (argc != 2) { std::cerr << "bufferedlogskiptest must be called with one argument\n"; - exit(EXIT_FAILURE); + return EXIT_FAILURE; } ns_log::Logger::fakePid = true; uint64_t timer; @@ -81,5 +81,5 @@ main(int argc, char **argv) reset(timer); testSkipBufferOnDebug(argv[1], timer); - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } diff --git a/vespalog/src/test/bufferedlogtest.cpp b/vespalog/src/test/bufferedlogtest.cpp index 09e103986ac..4035e98653f 100644 --- a/vespalog/src/test/bufferedlogtest.cpp +++ b/vespalog/src/test/bufferedlogtest.cpp @@ -8,6 +8,7 @@ #include <fstream> #include <iostream> #include <unistd.h> +#include <cstdlib> LOG_SETUP("bufferedlogtest"); @@ -98,7 +99,7 @@ void testThatEntriesWithHighCountIsKept(const std::string& file, uint64_t& timer [[maybe_unused]] int systemResult = system(("diff -u " + file + " bufferedlogtest.highcountkept.log") .c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); } @@ -134,7 +135,7 @@ void testThatEntriesWithHighCountsAreEventuallyRemoved( [[maybe_unused]] int systemResult = system(("diff -u " + file + " bufferedlogtest.highcountexpire.log") .c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); } @@ -168,7 +169,7 @@ void testThatEntriesExpire( << "testThatEntriesExpire\n"; [[maybe_unused]] int systemResult = system(("diff -u " + file + " bufferedlogtest.expire.log").c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); } @@ -237,7 +238,7 @@ void testThatHighCountEntriesDontStarveOthers( << "testThatHighCountEntriesDontStarveOthers\n"; [[maybe_unused]] int systemResult = system(("diff -u " + file + " bufferedlogtest.nostarve.log").c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); } @@ -270,7 +271,7 @@ void testNoTokenMatchAcrossComponents(const std::string& file, [[maybe_unused]] int systemResult = system(("diff -u " + file + " bufferedlogtest.tokenacrossloggers.log").c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); } @@ -299,7 +300,7 @@ void testLogLocationAsToken(const std::string& file, uint64_t& timer) [[maybe_unused]] int systemResult = system(("diff -u " + file + " bufferedlogtest.locationastoken.log").c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); } @@ -328,7 +329,7 @@ void testLogMessageAsToken(const std::string& file, uint64_t& timer) [[maybe_unused]] int systemResult = system(("diff -u " + file + " bufferedlogtest.messageastoken.log").c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); } @@ -363,7 +364,7 @@ void testNonBufferedLoggerTriggersBufferedLogTrim(const std::string& file, [[maybe_unused]] int systemResult = system(("diff -u " + file + " bufferedlogtest.trimcache.log").c_str()); - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } unlink(file.c_str()); @@ -380,7 +381,7 @@ main(int argc, char **argv) { if (argc != 2) { std::cerr << "bufferedlogtest must be called with one argument\n"; - exit(EXIT_FAILURE); + return EXIT_FAILURE; } ns_log::Logger::fakePid = true; ns_log::BufferedLogger::logger.setMaxCacheSize(10); @@ -405,5 +406,5 @@ main(int argc, char **argv) reset(timer); testNonBufferedLoggerTriggersBufferedLogTrim(argv[1], timer); - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } diff --git a/vespalog/src/test/logtest.cpp b/vespalog/src/test/logtest.cpp index 42b7bfc6ef9..a95bea9e31c 100644 --- a/vespalog/src/test/logtest.cpp +++ b/vespalog/src/test/logtest.cpp @@ -33,5 +33,5 @@ main(int, char **argv) LOG(info, "Exiting."); EV_STOPPING("logtest", "clean exit"); EV_STOPPED("logtest", getpid(), 0); - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } diff --git a/vespalog/src/test/rejectfiltertest.cpp b/vespalog/src/test/rejectfiltertest.cpp index d79d621c780..3125c05b959 100644 --- a/vespalog/src/test/rejectfiltertest.cpp +++ b/vespalog/src/test/rejectfiltertest.cpp @@ -5,6 +5,7 @@ #include <stdlib.h> #include <unistd.h> #include <iostream> +#include <cstdlib> using ns_log::RejectFilter; using ns_log::Logger; @@ -15,7 +16,7 @@ assertShouldNotReject(RejectFilter & filter, Logger::LogLevel level, const char std::cerr << "Filter should not reject level '" << Logger::levelName(level) << "' message '" << (msg == NULL ? "NULL" : msg) << "' ...: "; if (filter.shouldReject(level, msg)) { std::cerr << "Failed!\n"; - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } std::cerr << "Success!\n"; } @@ -26,7 +27,7 @@ assertShouldReject(RejectFilter & filter, Logger::LogLevel level, const char * m std::cerr << "Filter should reject level '" << Logger::levelName(level) << "' message '" << (msg == NULL ? "NULL" : msg) << "' ...: "; if (!filter.shouldReject(level, msg)) { std::cerr << "Failed!\n"; - exit(EXIT_FAILURE); + std::_Exit(EXIT_FAILURE); } std::cerr << "Success!\n"; } @@ -53,5 +54,5 @@ main(int argc, char **argv) assertShouldNotReject(defaultFilter, Logger::warning, "foobar"); assertShouldNotReject(defaultFilter, Logger::event, NULL); assertShouldReject(defaultFilter, Logger::warning, "E 18-140313.398540 10727 18/11/2012 14:03:13 yjava_preload.so: [preload.c:670] Accept failed: -1 (4)"); - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } diff --git a/vespalog/src/test/simple/logtest.cpp b/vespalog/src/test/simple/logtest.cpp index 020c97dd1a8..7951b488052 100644 --- a/vespalog/src/test/simple/logtest.cpp +++ b/vespalog/src/test/simple/logtest.cpp @@ -33,5 +33,5 @@ main(int, char **argv) LOG(info, "Exiting."); EV_STOPPING("logtest", "clean exit"); EV_STOPPED("logtest", getpid(), 0); - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } diff --git a/vespalog/src/test/threads/testthreads.cpp b/vespalog/src/test/threads/testthreads.cpp index ab7ddad3da7..465d2c6e3f8 100644 --- a/vespalog/src/test/threads/testthreads.cpp +++ b/vespalog/src/test/threads/testthreads.cpp @@ -9,6 +9,7 @@ #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> +#include <cstdlib> using std::string; using namespace std::chrono_literals; @@ -44,18 +45,18 @@ FileThread::Run(FastOS_ThreadInterface *, void *) int fd = open(_file.c_str(), O_RDWR | O_CREAT | O_APPEND, 0644); if (fd == -1) { fprintf(stderr, "open failed: %s\n", strerror(errno)); - exit(1); + std::_Exit(1); } std::this_thread::sleep_for(5ms); struct stat buf; fstat(fd, &buf); if (buf.st_size != 0) { fprintf(stderr, "%s isn't empty anymore\n", _file.c_str()); - exit(1); + std::_Exit(1); } if (close(fd) != 0) { fprintf(stderr, "close of %d failed: %s\n", fd, strerror(errno)); - exit(1); + std::_Exit(1); } } } diff --git a/vespalog/src/vespa-logfmt/logfilter.c b/vespalog/src/vespa-logfmt/logfilter.c index 2db108771ee..1af97751011 100644 --- a/vespalog/src/vespa-logfmt/logfilter.c +++ b/vespalog/src/vespa-logfmt/logfilter.c @@ -5,6 +5,7 @@ #include <sys/wait.h> #include <unistd.h> #include <csignal> +#include <cstdlib> int main(int argc, char *argv[]) { @@ -15,7 +16,7 @@ int main(int argc, char *argv[]) if (argc < 3) { fprintf(stderr, "Usage: %s logfmt prog [...]\n", argv[0]); - exit(1); + return 1; } pipe(lfpipe); @@ -29,11 +30,11 @@ int main(int argc, char *argv[]) } execlp(argv[1], argv[1], "-", (const char *)NULL); perror("exec logfmt failed"); - exit(1); + std::_Exit(1); } if (lfmtpid < 0) { perror("fork failed"); - exit(1); + return 1; } close(lfpipe[0]); @@ -50,11 +51,11 @@ int main(int argc, char *argv[]) argv[i-2] = NULL; execvp(argv[0], argv); perror("exec program failed"); - exit(1); + std::_Exit(1); } if (progpid < 0) { perror("fork failed"); - exit(1); + return 1; } close(lfpipe[1]); @@ -74,5 +75,5 @@ int main(int argc, char *argv[]) kill(getpid(), sig); } /* should not get here */ - exit(1); + return 1; } |