An option to specify a custom directory for temporary client library copies

This commit is contained in:
Vaidas Gasiunas 2022-04-21 18:53:08 +02:00
parent 98b82f1ac3
commit e48ab69c6b
3 changed files with 10 additions and 2 deletions

View File

@ -1996,8 +1996,9 @@ std::vector<std::pair<std::string, bool>> MultiVersionApi::copyExternalLibraryPe
for (int ii = 0; ii < threadCount; ++ii) { for (int ii = 0; ii < threadCount; ++ii) {
std::string filename = basename(path); std::string filename = basename(path);
char tempName[PATH_MAX + 12]; constexpr int MAX_TMP_NAME_LENGTH = PATH_MAX + 12;
sprintf(tempName, "/tmp/%s-XXXXXX", filename.c_str()); char tempName[MAX_TMP_NAME_LENGTH];
snprintf(tempName, MAX_TMP_NAME_LENGTH, "%s/%s-XXXXXX", tmpDir.c_str(), filename.c_str());
int tempFd = mkstemp(tempName); int tempFd = mkstemp(tempName);
int fd; int fd;
@ -2143,6 +2144,9 @@ void MultiVersionApi::setNetworkOptionInternal(FDBNetworkOptions::Option option,
// multiple client threads are not supported on windows. // multiple client threads are not supported on windows.
threadCount = extractIntOption(value, 1, 1); threadCount = extractIntOption(value, 1, 1);
#endif #endif
} else if (option == FDBNetworkOptions::CLIENT_TMP_DIR) {
validateOption(value, true, false, false);
tmpDir = abspath(value.get().toString());
} else { } else {
forwardOption = true; forwardOption = true;
} }

View File

@ -898,6 +898,7 @@ private:
int nextThread = 0; int nextThread = 0;
int threadCount; int threadCount;
std::string tmpDir;
Mutex lock; Mutex lock;
std::vector<std::pair<FDBNetworkOptions::Option, Optional<Standalone<StringRef>>>> options; std::vector<std::pair<FDBNetworkOptions::Option, Optional<Standalone<StringRef>>>> options;

View File

@ -134,6 +134,9 @@ description is not currently required but encouraged.
<Option name="distributed_client_tracer" code="90" <Option name="distributed_client_tracer" code="90"
paramType="String" paramDescription="Distributed tracer type. Choose from none, log_file, or network_lossy" paramType="String" paramDescription="Distributed tracer type. Choose from none, log_file, or network_lossy"
description="Set a tracer to run on the client. Should be set to the same value as the tracer set on the server." /> description="Set a tracer to run on the client. Should be set to the same value as the tracer set on the server." />
<Option name="client_tmp_dir" code="90"
paramType="String" paramDescription="Client directory for temporary files. "
description="Sets the directory for storing temporary files created by FDB client, such as temporary copies of client libraries. Defaults to /tmp" />
<Option name="supported_client_versions" code="1000" <Option name="supported_client_versions" code="1000"
paramType="String" paramDescription="[release version],[source version],[protocol version];..." paramType="String" paramDescription="[release version],[source version],[protocol version];..."
description="This option is set automatically to communicate the list of supported clients to the active client." description="This option is set automatically to communicate the list of supported clients to the active client."