diff options
| author | Tomasz Obrębski <[email protected]> | 2025-12-19 18:55:00 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-12-19 18:55:00 +0100 |
| commit | b01ad05dcf31c131f25438ca7df3708f0ddd47b4 (patch) | |
| tree | 52b65394418c475fd13312fc46aad3cab0413076 /src | |
| parent | Merge pull request #696 from ue-foundation/zs/limit-overwrite-default (diff) | |
| download | zen-b01ad05dcf31c131f25438ca7df3708f0ddd47b4.tar.xz zen-b01ad05dcf31c131f25438ca7df3708f0ddd47b4.zip | |
Add base port getter and set the dll directory for plugin dependencies (#692)
* Add base port getter and set the dll directory for plugin dependencies
* Use UTF8 for dll paths
* Rename BasePort to m_BasePort for consistency
Diffstat (limited to 'src')
| -rw-r--r-- | src/transports/transport-sdk/include/transportplugin.h | 1 | ||||
| -rw-r--r-- | src/zenhttp/servers/httpplugin.cpp | 13 | ||||
| -rw-r--r-- | src/zenhttp/transports/dlltransport.cpp | 14 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/transports/transport-sdk/include/transportplugin.h b/src/transports/transport-sdk/include/transportplugin.h index a78a758bc..9bb2d6219 100644 --- a/src/transports/transport-sdk/include/transportplugin.h +++ b/src/transports/transport-sdk/include/transportplugin.h @@ -62,6 +62,7 @@ class TransportServer { public: virtual TransportServerConnection* CreateConnectionHandler(TransportConnection* Connection) = 0; + virtual int GetBasePort() const = 0; }; /** Logger interface diff --git a/src/zenhttp/servers/httpplugin.cpp b/src/zenhttp/servers/httpplugin.cpp index 44a5b71d0..7ee4c6e62 100644 --- a/src/zenhttp/servers/httpplugin.cpp +++ b/src/zenhttp/servers/httpplugin.cpp @@ -120,12 +120,14 @@ struct HttpPluginServerImpl : public HttpPluginServer, TransportServer bool m_IsRequestLoggingEnabled = false; LoggerRef m_RequestLog; std::atomic_uint32_t m_ConnectionIdCounter{0}; + int m_BasePort; HttpServerTracer m_RequestTracer; // TransportServer virtual TransportServerConnection* CreateConnectionHandler(TransportConnection* Connection) override; + virtual int GetBasePort() const override; }; /** This is the class which request handlers interface with when @@ -707,12 +709,19 @@ HttpPluginServerImpl::CreateConnectionHandler(TransportConnection* Connection) } int -HttpPluginServerImpl::OnInitialize(int BasePort, std::filesystem::path DataDir) +HttpPluginServerImpl::GetBasePort() const +{ + return m_BasePort; +} + +int +HttpPluginServerImpl::OnInitialize(int InBasePort, std::filesystem::path DataDir) { ZEN_TRACE_CPU("HttpPluginServerImpl::Initialize"); ZEN_MEMSCOPE(GetHttppluginTag()); m_RequestTracer.Initialize(DataDir); + m_BasePort = InBasePort; try { @@ -737,7 +746,7 @@ HttpPluginServerImpl::OnInitialize(int BasePort, std::filesystem::path DataDir) m_IsInitialized = true; - return BasePort; + return m_BasePort; } void diff --git a/src/zenhttp/transports/dlltransport.cpp b/src/zenhttp/transports/dlltransport.cpp index fb3dd23b5..9135d5425 100644 --- a/src/zenhttp/transports/dlltransport.cpp +++ b/src/zenhttp/transports/dlltransport.cpp @@ -6,6 +6,7 @@ #include <zencore/fmtutils.h> #include <zencore/logging.h> #include <zencore/scopeguard.h> +#include <zencore/string.h> #include <exception> #include <thread> @@ -177,7 +178,7 @@ DllTransportPluginImpl::LoadDll(std::string_view Name) { RwLock::ExclusiveLockScope _(m_Lock); - ExtendableStringBuilder<1024> DllPath; + WideStringBuilder<1024> DllPath; DllPath << Name; if (!Name.ends_with(".dll")) { @@ -185,12 +186,15 @@ DllTransportPluginImpl::LoadDll(std::string_view Name) } std::string FileName = std::filesystem::path(DllPath.c_str()).filename().replace_extension().string(); + std::string Path = std::filesystem::path(DllPath.c_str()).parent_path().string(); - HMODULE DllHandle = LoadLibraryA(DllPath.c_str()); + SetDllDirectoryW(Utf8ToWide(Path).c_str()); + + HMODULE DllHandle = LoadLibraryW(DllPath.c_str()); if (!DllHandle) { - ZEN_WARN("Failed to load transport DLL from '{}' due to '{}'", DllPath, GetLastErrorAsString()) + ZEN_WARN("Failed to load transport DLL from '{}' due to '{}'", WideToUtf8(DllPath), GetLastErrorAsString()) return false; } @@ -216,14 +220,14 @@ DllTransportPluginImpl::LoadDll(std::string_view Name) if (GetVersion && !bValidApiVersion) { ZEN_WARN("Failed to load transport DLL from '{}' due to invalid API version {}, supported API version is {}", - DllPath, + WideToUtf8(DllPath), APIVersion, kTransportApiVersion) } else { ZEN_WARN("Failed to load transport DLL from '{}' due to not finding GetTransportPluginVersion or CreateTransportPlugin", - DllPath) + WideToUtf8(DllPath)) } return false; |