aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-09-17 13:11:04 +0200
committerPer Larsson <[email protected]>2021-09-17 13:11:04 +0200
commitd812fcc3eab88733cbef084eefd089d22177aae4 (patch)
treebb64fa6c64f9707246577de148749b35d1e25987
parentAdded helper function for iterating string tokens. (diff)
parentAdded namespace scopes to more includes for better consistency (diff)
downloadzen-d812fcc3eab88733cbef084eefd089d22177aae4.tar.xz
zen-d812fcc3eab88733cbef084eefd089d22177aae4.zip
Merge branch 'main' of https://github.com/EpicGames/zen
-rw-r--r--zen/cmds/cache.cpp2
-rw-r--r--zen/cmds/copy.cpp4
-rw-r--r--zen/cmds/copy.h4
-rw-r--r--zen/cmds/dedup.cpp4
-rw-r--r--zen/cmds/dedup.h4
-rw-r--r--zen/cmds/deploy.cpp4
-rw-r--r--zen/cmds/deploy.h4
-rw-r--r--zen/cmds/hash.cpp4
-rw-r--r--zen/cmds/hash.h4
-rw-r--r--zen/cmds/run.cpp6
-rw-r--r--zen/cmds/run.h5
-rw-r--r--zen/cmds/scrub.cpp23
-rw-r--r--zen/cmds/scrub.h20
-rw-r--r--zen/cmds/status.cpp5
-rw-r--r--zen/cmds/status.h4
-rw-r--r--zen/cmds/top.cpp26
-rw-r--r--zen/cmds/top.h4
-rw-r--r--zen/cmds/up.cpp6
-rw-r--r--zen/cmds/up.h4
-rw-r--r--zen/zen.cpp50
-rw-r--r--zencore-test/zencore-test.cpp2
-rw-r--r--zencore/include/zencore/thread.h4
-rw-r--r--zencore/include/zencore/uid.h1
-rw-r--r--zencore/include/zencore/zencore.h4
-rw-r--r--zencore/thread.cpp4
-rw-r--r--zencore/uid.cpp8
-rw-r--r--zencore/zencore.cpp8
-rw-r--r--zenserver-test/zenserver-test.cpp11
-rw-r--r--zenserver/diag/logging.cpp6
-rw-r--r--zenserver/upstream/jupiter.cpp12
-rw-r--r--zenserver/zenserver.cpp8
-rw-r--r--zenutil/include/zenutil/zenserverprocess.h (renamed from zenutil/include/zenserverprocess.h)16
-rw-r--r--zenutil/zenserverprocess.cpp62
-rw-r--r--zenutil/zenutil.vcxproj5
-rw-r--r--zenutil/zenutil.vcxproj.filters5
35 files changed, 250 insertions, 93 deletions
diff --git a/zen/cmds/cache.cpp b/zen/cmds/cache.cpp
index 69e500293..202bf9246 100644
--- a/zen/cmds/cache.cpp
+++ b/zen/cmds/cache.cpp
@@ -5,7 +5,7 @@
#include <zencore/filesystem.h>
#include <zencore/logging.h>
#include <zenhttp/httpcommon.h>
-#include <zenserverprocess.h>
+#include <zenutil/zenserverprocess.h>
#include <memory>
diff --git a/zen/cmds/copy.cpp b/zen/cmds/copy.cpp
index 4ce09c982..6b3965f99 100644
--- a/zen/cmds/copy.cpp
+++ b/zen/cmds/copy.cpp
@@ -7,6 +7,8 @@
#include <zencore/string.h>
#include <zencore/timer.h>
+namespace zen {
+
CopyCommand::CopyCommand()
{
m_Options.add_options()("h,help", "Print help");
@@ -94,3 +96,5 @@ CopyCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
+
+}
diff --git a/zen/cmds/copy.h b/zen/cmds/copy.h
index 22b240d11..c2a7fd23b 100644
--- a/zen/cmds/copy.h
+++ b/zen/cmds/copy.h
@@ -4,6 +4,8 @@
#include "../zen.h"
+namespace zen {
+
/** Copy files, possibly using block cloning
*/
class CopyCommand : public ZenCmdBase
@@ -22,3 +24,5 @@ private:
std::string m_CopyTarget;
bool m_NoClone = false;
};
+
+}
diff --git a/zen/cmds/dedup.cpp b/zen/cmds/dedup.cpp
index 90a4fea76..f95a87518 100644
--- a/zen/cmds/dedup.cpp
+++ b/zen/cmds/dedup.cpp
@@ -12,6 +12,8 @@
#include <ppl.h>
+namespace zen {
+
DedupCommand::DedupCommand()
{
m_Options.add_options()("h,help", "Print help");
@@ -290,3 +292,5 @@ DedupCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
+
+}
diff --git a/zen/cmds/dedup.h b/zen/cmds/dedup.h
index 0f0aecc8e..c955d4bbd 100644
--- a/zen/cmds/dedup.h
+++ b/zen/cmds/dedup.h
@@ -6,6 +6,8 @@
#include <ppl.h>
+namespace zen {
+
/** Deduplicate files in a tree using block cloning
*/
class DedupCommand : public ZenCmdBase
@@ -24,3 +26,5 @@ private:
std::string m_DedupTarget;
size_t m_SizeThreshold = 1024 * 1024;
};
+
+}
diff --git a/zen/cmds/deploy.cpp b/zen/cmds/deploy.cpp
index b8879fefb..faaf0030c 100644
--- a/zen/cmds/deploy.cpp
+++ b/zen/cmds/deploy.cpp
@@ -5,6 +5,8 @@
#include <zencore/logging.h>
#include <zencore/string.h>
+namespace zen {
+
DeployCommand::DeployCommand()
{
m_Options.add_options()("h,help", "Print help");
@@ -80,3 +82,5 @@ DeployCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
+
+}
diff --git a/zen/cmds/deploy.h b/zen/cmds/deploy.h
index 1109aaf17..565e11bf3 100644
--- a/zen/cmds/deploy.h
+++ b/zen/cmds/deploy.h
@@ -4,6 +4,8 @@
#include "../zen.h"
+namespace zen {
+
/** Deploy files from Zen build store
*/
class DeployCommand : public ZenCmdBase
@@ -23,3 +25,5 @@ private:
bool m_NoClone = false;
bool m_IsClean = false;
};
+
+}
diff --git a/zen/cmds/hash.cpp b/zen/cmds/hash.cpp
index b6276dbc1..e9484c453 100644
--- a/zen/cmds/hash.cpp
+++ b/zen/cmds/hash.cpp
@@ -9,6 +9,8 @@
#include <ppl.h>
+namespace zen {
+
HashCommand::HashCommand()
{
m_Options.add_options()("d,dir", "Directory to scan", cxxopts::value<std::string>(m_ScanDirectory))(
@@ -123,3 +125,5 @@ HashCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
// TODO: implement snapshot enumeration and display
return 0;
}
+
+}
diff --git a/zen/cmds/hash.h b/zen/cmds/hash.h
index b994b497d..8ed8e9fa3 100644
--- a/zen/cmds/hash.h
+++ b/zen/cmds/hash.h
@@ -7,6 +7,8 @@
#include <ppl.h>
+namespace zen {
+
/** Generate hash list file
*/
class HashCommand : public ZenCmdBase
@@ -23,3 +25,5 @@ private:
std::string m_ScanDirectory;
std::string m_OutputFile;
};
+
+}
diff --git a/zen/cmds/run.cpp b/zen/cmds/run.cpp
index e5210f695..711a3a341 100644
--- a/zen/cmds/run.cpp
+++ b/zen/cmds/run.cpp
@@ -12,7 +12,7 @@
#include <zencore/logging.h>
#include <zencore/string.h>
#include <zencore/timer.h>
-#include <zenserverprocess.h>
+#include <zenutil/zenserverprocess.h>
#include <filesystem>
@@ -35,6 +35,8 @@
//////////////////////////////////////////////////////////////////////////
+namespace zen {
+
using namespace std::literals;
RunCommand::RunCommand()
@@ -181,3 +183,5 @@ RunCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
+
+}
diff --git a/zen/cmds/run.h b/zen/cmds/run.h
index 8fa1f6ae9..f4eb4ef76 100644
--- a/zen/cmds/run.h
+++ b/zen/cmds/run.h
@@ -2,10 +2,9 @@
#pragma once
-#include "../internalfile.h"
#include "../zen.h"
-#include <ppl.h>
+namespace zen {
/** Execute a command (using Zen)
*/
@@ -23,3 +22,5 @@ private:
std::string m_TargetHost;
std::string m_ExeTree;
};
+
+}
diff --git a/zen/cmds/scrub.cpp b/zen/cmds/scrub.cpp
index a9b8505ec..73d2b45ee 100644
--- a/zen/cmds/scrub.cpp
+++ b/zen/cmds/scrub.cpp
@@ -1,9 +1,12 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "scrub.h"
+#include <zenutil/zenserverprocess.h>
using namespace std::literals;
+namespace zen {
+
ScrubCommand::ScrubCommand()
{
}
@@ -17,3 +20,23 @@ ScrubCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
+
+//////////////////////////////////////////////////////////////////////////
+
+GcCommand::GcCommand()
+{
+}
+
+GcCommand::~GcCommand()
+{
+}
+
+int
+GcCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
+{
+ ZEN_UNUSED(GlobalOptions, argc, argv);
+
+ return 0;
+}
+
+}
diff --git a/zen/cmds/scrub.h b/zen/cmds/scrub.h
index 1bfb4ad6c..a3f25c259 100644
--- a/zen/cmds/scrub.h
+++ b/zen/cmds/scrub.h
@@ -2,10 +2,9 @@
#pragma once
-#include "../internalfile.h"
#include "../zen.h"
-#include <ppl.h>
+namespace zen {
/** Scrub storage
*/
@@ -21,3 +20,20 @@ public:
private:
cxxopts::Options m_Options{"scrub", "Scrub zen storage"};
};
+
+/** Garbage collect storage
+ */
+class GcCommand : public ZenCmdBase
+{
+public:
+ GcCommand();
+ ~GcCommand();
+
+ virtual int Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
+ virtual cxxopts::Options* Options() override { return &m_Options; }
+
+private:
+ cxxopts::Options m_Options{"gc", "Garbage collect zen storage"};
+};
+
+}
diff --git a/zen/cmds/status.cpp b/zen/cmds/status.cpp
index 6741ab9e9..1050b5b96 100644
--- a/zen/cmds/status.cpp
+++ b/zen/cmds/status.cpp
@@ -3,7 +3,8 @@
#include "status.h"
#include <zencore/logging.h>
-#include <memory>
+
+namespace zen {
StatusCommand::StatusCommand()
{
@@ -18,3 +19,5 @@ StatusCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
+
+}
diff --git a/zen/cmds/status.h b/zen/cmds/status.h
index bb439f340..f2c68b96a 100644
--- a/zen/cmds/status.h
+++ b/zen/cmds/status.h
@@ -4,6 +4,8 @@
#include "../zen.h"
+namespace zen {
+
class StatusCommand : public ZenCmdBase
{
public:
@@ -16,3 +18,5 @@ public:
private:
cxxopts::Options m_Options{"status", "Show zen status"};
};
+
+}
diff --git a/zen/cmds/top.cpp b/zen/cmds/top.cpp
index b0d684705..3ff7edcda 100644
--- a/zen/cmds/top.cpp
+++ b/zen/cmds/top.cpp
@@ -3,12 +3,16 @@
#include "top.h"
#include <zencore/logging.h>
-#include <zenserverprocess.h>
+#include <zencore/uid.h>
+#include <zencore/fmtutils.h>
+#include <zenutil/zenserverprocess.h>
#include <memory>
//////////////////////////////////////////////////////////////////////////
+namespace zen {
+
TopCommand::TopCommand()
{
}
@@ -28,7 +32,23 @@ TopCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
- State.Snapshot([&](const ZenServerState::ZenServerEntry& Entry) { ZEN_INFO("Port {} : pid {}", Entry.ListenPort, Entry.Pid); });
+ int n = 0;
+ const int HeaderPeriod = 20;
+
+ for (;;)
+ {
+ if ((n++ % HeaderPeriod) == 0)
+ {
+ ZEN_CONSOLE("{:>5} {:>6} {:>24}", "port", "pid", "session");
+ }
+
+ State.Snapshot([&](const ZenServerState::ZenServerEntry& Entry) { ZEN_CONSOLE("{:5} {:6} {:24}", Entry.ListenPort, Entry.Pid, Entry.GetSessionId()); });
+
+ zen::Sleep(1000);
+
+ State.Sweep();
+ }
+
return 0;
}
@@ -58,3 +78,5 @@ PsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
+
+}
diff --git a/zen/cmds/top.h b/zen/cmds/top.h
index 32ba6c57b..a842089ff 100644
--- a/zen/cmds/top.h
+++ b/zen/cmds/top.h
@@ -4,6 +4,8 @@
#include "../zen.h"
+namespace zen {
+
class TopCommand : public ZenCmdBase
{
public:
@@ -29,3 +31,5 @@ public:
private:
cxxopts::Options m_Options{"ps", "Enumerate running Zen server instances"};
};
+
+}
diff --git a/zen/cmds/up.cpp b/zen/cmds/up.cpp
index a1047fd57..048133fc9 100644
--- a/zen/cmds/up.cpp
+++ b/zen/cmds/up.cpp
@@ -4,10 +4,12 @@
#include <zencore/filesystem.h>
#include <zencore/logging.h>
-#include <zenserverprocess.h>
+#include <zenutil/zenserverprocess.h>
#include <memory>
+namespace zen {
+
UpCommand::UpCommand()
{
}
@@ -98,3 +100,5 @@ DownCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return 0;
}
+
+}
diff --git a/zen/cmds/up.h b/zen/cmds/up.h
index a3c6eaa06..fda62693a 100644
--- a/zen/cmds/up.h
+++ b/zen/cmds/up.h
@@ -4,6 +4,8 @@
#include "../zen.h"
+namespace zen {
+
class UpCommand : public ZenCmdBase
{
public:
@@ -29,3 +31,5 @@ public:
private:
cxxopts::Options m_Options{"down", "Bring down zen service"};
};
+
+}
diff --git a/zen/zen.cpp b/zen/zen.cpp
index d8bfa13e5..6390c832f 100644
--- a/zen/zen.cpp
+++ b/zen/zen.cpp
@@ -42,6 +42,7 @@
//////////////////////////////////////////////////////////////////////////
+
class TemplateCommand : public ZenCmdBase
{
public:
@@ -94,29 +95,12 @@ private:
int
main(int argc, char** argv)
{
+ using namespace zen;
+
mi_version();
zen::logging::InitializeLogging();
-#if TEST_UWS
- /* Overly simple hello world app, using multiple threads */
- std::vector<std::thread*> threads(4);
-
- std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread* /*t*/) {
- return new std::thread([]() {
- uWS::App()
- .get("/*",
- [&](uWS::HttpResponse<false>* res, uWS::HttpRequest*) {
- zen::Sleep(1);
- res->end("hello, world!");
- })
- .listen(1337, [&](auto* listen_socket) { ZEN_UNUSED(listen_socket); })
- .run();
- });
- });
-
- std::for_each(threads.begin(), threads.end(), [](std::thread* t) { t->join(); });
-#endif
//////////////////////////////////////////////////////////////////////////
auto _ = zen::MakeGuard([] { spdlog::shutdown(); });
@@ -141,19 +125,21 @@ main(int argc, char** argv)
ZenCmdBase* Cmd;
const char* CmdSummary;
} Commands[] = {
- {"chunk", &ChunkCmd, "Perform chunking"},
- {"copy", &CopyCmd, "Copy file(s)"},
- {"deploy", &DeployCmd, "Deploy data"},
- {"dedup", &DedupCmd, "Dedup files"},
- {"drop", &DropCmd, "Drop cache bucket(s)"},
- {"hash", &HashCmd, "Compute file hashes"},
- {"runtests", &RunTestsCmd, "Run zen tests"},
- {"run", &RunCmd, "Remote execution"},
- {"status", &StatusCmd, "Show zen status"},
- {"ps", &PsCmd, "Enumerate running zen server instances"},
- {"top", &TopCmd, "Monitor zen server activity"},
- {"up", &UpCmd, "Bring zen server up"},
- {"down", &DownCmd, "Bring zen server down"},
+ // clang-format off
+ {"chunk", &ChunkCmd, "Perform chunking"},
+ {"copy", &CopyCmd, "Copy file(s)"},
+ {"deploy", &DeployCmd, "Deploy data"},
+ {"dedup", &DedupCmd, "Dedup files"},
+ {"drop", &DropCmd, "Drop cache bucket(s)"},
+ {"hash", &HashCmd, "Compute file hashes"},
+ {"runtests", &RunTestsCmd, "Run zen tests"},
+ {"run", &RunCmd, "Remote execution"},
+ {"status", &StatusCmd, "Show zen status"},
+ {"ps", &PsCmd, "Enumerate running zen server instances"},
+ {"top", &TopCmd, "Monitor zen server activity"},
+ {"up", &UpCmd, "Bring zen server up"},
+ {"down", &DownCmd, "Bring zen server down"},
+ // clang-format on
};
// Build set containing available commands
diff --git a/zencore-test/zencore-test.cpp b/zencore-test/zencore-test.cpp
index 559349076..7242a30ec 100644
--- a/zencore-test/zencore-test.cpp
+++ b/zencore-test/zencore-test.cpp
@@ -11,7 +11,7 @@
void
forceLinkTests()
{
- zencore_forcelinktests();
+ zen::zencore_forcelinktests();
}
int
diff --git a/zencore/include/zencore/thread.h b/zencore/include/zencore/thread.h
index 0e34d6518..e65867ec4 100644
--- a/zencore/include/zencore/thread.h
+++ b/zencore/include/zencore/thread.h
@@ -128,7 +128,7 @@ private:
};
/** Basic process abstraction
- */
+ */
class ProcessHandle
{
public:
@@ -155,7 +155,7 @@ private:
/** Process monitor - monitors a list of running processes via polling
- Intended to be used to monitor a set of "sponsor" processes, where
+ Intended to be used to monitor a set of "sponsor" processes, where
we need to determine when none of them remain alive
*/
diff --git a/zencore/include/zencore/uid.h b/zencore/include/zencore/uid.h
index 2730b1415..f095c49ef 100644
--- a/zencore/include/zencore/uid.h
+++ b/zencore/include/zencore/uid.h
@@ -60,6 +60,7 @@ struct Oid
const Oid& Generate();
[[nodiscard]] static Oid FromHexString(const std::string_view String);
StringBuilderBase& ToString(StringBuilderBase& OutString) const;
+ [[nodiscard]] static Oid FromMemory(const void* Ptr);
auto operator<=>(const Oid& rhs) const = default;
[[nodiscard]] inline operator bool() const { return *this == Zero; }
diff --git a/zencore/include/zencore/zencore.h b/zencore/include/zencore/zencore.h
index 54df7e85e..da17e61e3 100644
--- a/zencore/include/zencore/zencore.h
+++ b/zencore/include/zencore/zencore.h
@@ -150,12 +150,16 @@ char (&ZenArrayCountHelper(const T (&)[N]))[N + 1];
#define ZEN_NOT_IMPLEMENTED(...) ZEN_ASSERT(false, __VA_ARGS__)
#define ZENCORE_API // Placeholder to allow DLL configs in the future
+namespace zen {
+
ZENCORE_API bool IsPointerToStack(const void* ptr); // Query if pointer is within the stack of the currently executing thread
ZENCORE_API bool IsApplicationExitRequested();
ZENCORE_API void RequestApplicationExit(int ExitCode);
ZENCORE_API void zencore_forcelinktests();
+}
+
//////////////////////////////////////////////////////////////////////////
#if ZEN_COMPILER_MSC
diff --git a/zencore/thread.cpp b/zencore/thread.cpp
index ee00d38d4..1c7e4b3ab 100644
--- a/zencore/thread.cpp
+++ b/zencore/thread.cpp
@@ -76,7 +76,7 @@ Event::Reset()
ResetEvent(m_EventHandle);
}
-void
+void
Event::Close()
{
CloseHandle(m_EventHandle);
@@ -291,7 +291,7 @@ ProcessMonitor::IsRunning()
{
DWORD ExitCode = 0;
GetExitCodeProcess(Proc, &ExitCode);
-
+
if (ExitCode != STILL_ACTIVE)
{
CloseHandle(Proc);
diff --git a/zencore/uid.cpp b/zencore/uid.cpp
index acf9f9790..d946638ec 100644
--- a/zencore/uid.cpp
+++ b/zencore/uid.cpp
@@ -83,6 +83,14 @@ Oid::FromHexString(const std::string_view String)
}
}
+Oid
+Oid::FromMemory(const void* Ptr)
+{
+ Oid Id;
+ memcpy(Id.OidBits, Ptr, sizeof Id);
+ return Id;
+}
+
StringBuilderBase&
Oid::ToString(StringBuilderBase& OutString) const
{
diff --git a/zencore/zencore.cpp b/zencore/zencore.cpp
index f179880e4..5899f014d 100644
--- a/zencore/zencore.cpp
+++ b/zencore/zencore.cpp
@@ -28,6 +28,8 @@
#include <zencore/timer.h>
#include <zencore/uid.h>
+namespace zen {
+
bool
IsPointerToStack(const void* ptr)
{
@@ -53,11 +55,11 @@ IsPointerToStack(const void* ptr)
#endif
}
-zen::AssertException::AssertException(const char* Msg) : m_Msg(Msg)
+AssertException::AssertException(const char* Msg) : m_Msg(Msg)
{
}
-zen::AssertException::~AssertException()
+AssertException::~AssertException()
{
}
@@ -101,3 +103,5 @@ zencore_forcelinktests()
zen::usonbuilder_forcelink();
zen::usonpackage_forcelink();
}
+
+} // namespace zen
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp
index 8a634107d..48bbacd80 100644
--- a/zenserver-test/zenserver-test.cpp
+++ b/zenserver-test/zenserver-test.cpp
@@ -19,7 +19,7 @@
#include <zenhttp/httpclient.h>
#include <zenhttp/httpshared.h>
#include <zenhttp/zenhttp.h>
-#include <zenserverprocess.h>
+#include <zenutil/zenserverprocess.h>
#include <mimalloc.h>
@@ -657,20 +657,20 @@ main()
}
#else
-ZenServerEnvironment TestEnv;
+zen::ZenServerEnvironment TestEnv;
int
main(int argc, char** argv)
{
mi_version();
- zencore_forcelinktests();
+ zen::zencore_forcelinktests();
zen::zenhttp_forcelinktests();
zen::logging::InitializeLogging();
spdlog::set_level(spdlog::level::debug);
- spdlog::set_formatter(std::make_unique<logging::full_formatter>("test", std::chrono::system_clock::now()));
+ spdlog::set_formatter(std::make_unique<::logging::full_formatter>("test", std::chrono::system_clock::now()));
std::filesystem::path ProgramBaseDir = std::filesystem::path(argv[0]).parent_path();
std::filesystem::path TestBaseDir = ProgramBaseDir.parent_path().parent_path() / ".test";
@@ -681,6 +681,8 @@ main(int argc, char** argv)
return doctest::Context(argc, argv).run();
}
+namespace zen::tests {
+
# if 1
TEST_CASE("asio.http")
{
@@ -1771,4 +1773,5 @@ TEST_CASE("lifetime.owner.2")
}
# endif
+}
#endif
diff --git a/zenserver/diag/logging.cpp b/zenserver/diag/logging.cpp
index 48eda7512..4ba4835af 100644
--- a/zenserver/diag/logging.cpp
+++ b/zenserver/diag/logging.cpp
@@ -204,6 +204,12 @@ InitializeLogging(const ZenServerOptions& GlobalOptions)
IsAsync = false;
}
+ if (GlobalOptions.IsTest)
+ {
+ LogLevel = spdlog::level::trace;
+ IsAsync = false;
+ }
+
if (IsAsync)
{
const int QueueSize = 8192;
diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp
index 4a5467648..fbd945528 100644
--- a/zenserver/upstream/jupiter.cpp
+++ b/zenserver/upstream/jupiter.cpp
@@ -163,7 +163,9 @@ CloudCacheSession::PutDerivedData(std::string_view BucketId, std::string_view Ke
cpr::Response Response = Session.Put();
ZEN_DEBUG("PUT {}", Response);
- return {.Bytes = Response.uploaded_bytes, .ElapsedSeconds = Response.elapsed, .Success = (Response.status_code == 200 || Response.status_code == 201)};
+ return {.Bytes = Response.uploaded_bytes,
+ .ElapsedSeconds = Response.elapsed,
+ .Success = (Response.status_code == 200 || Response.status_code == 201)};
}
CloudCacheResult
@@ -194,7 +196,9 @@ CloudCacheSession::PutRef(std::string_view BucketId, const IoHash& Key, IoBuffer
cpr::Response Response = Session.Put();
ZEN_DEBUG("PUT {}", Response);
- return {.Bytes = Response.uploaded_bytes, .ElapsedSeconds = Response.elapsed, .Success = (Response.status_code == 200 || Response.status_code == 201)};
+ return {.Bytes = Response.uploaded_bytes,
+ .ElapsedSeconds = Response.elapsed,
+ .Success = (Response.status_code == 200 || Response.status_code == 201)};
}
CloudCacheResult
@@ -215,7 +219,9 @@ CloudCacheSession::PutCompressedBlob(const IoHash& Key, IoBuffer Blob)
cpr::Response Response = Session.Put();
ZEN_DEBUG("PUT {}", Response);
- return {.Bytes = Response.uploaded_bytes, .ElapsedSeconds = Response.elapsed, .Success = (Response.status_code == 200 || Response.status_code == 201)};
+ return {.Bytes = Response.uploaded_bytes,
+ .ElapsedSeconds = Response.elapsed,
+ .Success = (Response.status_code == 200 || Response.status_code == 201)};
}
std::vector<IoHash>
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index f1960ab36..eb0324161 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -11,7 +11,7 @@
#include <zencore/timer.h>
#include <zencore/windows.h>
#include <zenhttp/httpserver.h>
-#include <zenserverprocess.h>
+#include <zenutil/zenserverprocess.h>
#include <zenstore/cas.h>
#include <zenstore/cidstore.h>
@@ -82,6 +82,8 @@
#define ZEN_APP_NAME "Zen store"
+namespace zen {
+
class ZenServer
{
ZenServerState::ZenServerEntry* m_ServerEntry = nullptr;
@@ -420,9 +422,13 @@ private:
bool m_DebugOptionForcedCrash = false;
};
+}
+
int
main(int argc, char* argv[])
{
+ using namespace zen;
+
mi_version();
ZenServerOptions GlobalOptions;
diff --git a/zenutil/include/zenserverprocess.h b/zenutil/include/zenutil/zenserverprocess.h
index b659f6e58..f0924f048 100644
--- a/zenutil/include/zenserverprocess.h
+++ b/zenutil/include/zenutil/zenserverprocess.h
@@ -5,6 +5,7 @@
#include <zencore/enumflags.h>
#include <zencore/logging.h>
#include <zencore/thread.h>
+#include <zencore/uid.h>
#include <gsl/gsl-lite.hpp>
@@ -12,6 +13,8 @@
#include <filesystem>
#include <optional>
+namespace zen {
+
class ZenServerEnvironment
{
public:
@@ -106,9 +109,10 @@ public:
FRIEND_ENUM_CLASS_FLAGS(FlagsEnum);
- void Reset();
- void SignalShutdownRequest();
- bool AddSponsorProcess(uint32_t Pid);
+ zen::Oid GetSessionId() const { return zen::Oid::FromMemory(SessionId); }
+ void Reset();
+ void SignalShutdownRequest();
+ bool AddSponsorProcess(uint32_t Pid);
};
static_assert(sizeof(ZenServerEntry) == 256);
@@ -121,8 +125,10 @@ public:
void Snapshot(std::function<void(const ZenServerEntry&)>&& Callback);
private:
- void* m_hMapFile = nullptr;
- ZenServerEntry* m_Data;
+ void* m_hMapFile = nullptr;
+ ZenServerEntry* m_Data = nullptr;
int m_MaxEntryCount = 131072 / sizeof(ZenServerEntry);
ZenServerEntry* m_OurEntry = nullptr;
};
+
+}
diff --git a/zenutil/zenserverprocess.cpp b/zenutil/zenserverprocess.cpp
index 2f2b3bd33..c504ce7da 100644
--- a/zenutil/zenserverprocess.cpp
+++ b/zenutil/zenserverprocess.cpp
@@ -1,6 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
-#include "zenserverprocess.h"
+#include "zenutil/zenserverprocess.h"
#include <zencore/except.h>
#include <zencore/filesystem.h>
@@ -17,44 +17,46 @@
//////////////////////////////////////////////////////////////////////////
+namespace zen {
+
namespace zenutil {
-class SecurityAttributes
-{
-public:
- inline SECURITY_ATTRIBUTES* Attributes() { return &m_Attributes; }
+ class SecurityAttributes
+ {
+ public:
+ inline SECURITY_ATTRIBUTES* Attributes() { return &m_Attributes; }
-protected:
- SECURITY_ATTRIBUTES m_Attributes{};
- SECURITY_DESCRIPTOR m_Sd{};
-};
+ protected:
+ SECURITY_ATTRIBUTES m_Attributes{};
+ SECURITY_DESCRIPTOR m_Sd{};
+ };
-// Security attributes which allows any user access
+ // Security attributes which allows any user access
-class AnyUserSecurityAttributes : public SecurityAttributes
-{
-public:
- AnyUserSecurityAttributes()
+ class AnyUserSecurityAttributes : public SecurityAttributes
{
- m_Attributes.nLength = sizeof m_Attributes;
- m_Attributes.bInheritHandle = false; // Disable inheritance
-
- const BOOL success = InitializeSecurityDescriptor(&m_Sd, SECURITY_DESCRIPTOR_REVISION);
-
- if (success)
+ public:
+ AnyUserSecurityAttributes()
{
- const BOOL bSetOk = SetSecurityDescriptorDacl(&m_Sd, TRUE, (PACL)NULL, FALSE);
+ m_Attributes.nLength = sizeof m_Attributes;
+ m_Attributes.bInheritHandle = false; // Disable inheritance
- if (bSetOk)
- {
- m_Attributes.lpSecurityDescriptor = &m_Sd;
- }
- else
+ const BOOL success = InitializeSecurityDescriptor(&m_Sd, SECURITY_DESCRIPTOR_REVISION);
+
+ if (success)
{
- zen::ThrowLastError("SetSecurityDescriptorDacl failed", std::source_location::current());
+ const BOOL bSetOk = SetSecurityDescriptorDacl(&m_Sd, TRUE, (PACL)NULL, FALSE);
+
+ if (bSetOk)
+ {
+ m_Attributes.lpSecurityDescriptor = &m_Sd;
+ }
+ else
+ {
+ zen::ThrowLastError("SetSecurityDescriptorDacl failed", std::source_location::current());
+ }
}
}
- }
-};
+ };
} // namespace zenutil
@@ -628,3 +630,5 @@ ZenServerInstance::GetBaseUri() const
return "http://localhost:{}"_format(m_BasePort);
}
+
+} // namespace zen
diff --git a/zenutil/zenutil.vcxproj b/zenutil/zenutil.vcxproj
index fcb27dff3..3bf6111f7 100644
--- a/zenutil/zenutil.vcxproj
+++ b/zenutil/zenutil.vcxproj
@@ -100,13 +100,16 @@
<ClCompile Include="zenserverprocess.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="include\zenserverprocess.h" />
+ <ClInclude Include="include\zenutil\zenserverprocess.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\zencore\zencore.vcxproj">
<Project>{d75bf9ab-c61e-4fff-ad59-1563430f05e2}</Project>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <None Include="xmake.lua" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/zenutil/zenutil.vcxproj.filters b/zenutil/zenutil.vcxproj.filters
index ca1414842..9952e7159 100644
--- a/zenutil/zenutil.vcxproj.filters
+++ b/zenutil/zenutil.vcxproj.filters
@@ -4,6 +4,9 @@
<ClCompile Include="zenserverprocess.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="include\zenserverprocess.h" />
+ <ClInclude Include="include\zenutil\zenserverprocess.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="xmake.lua" />
</ItemGroup>
</Project> \ No newline at end of file