aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2024-05-02 17:50:27 +0200
committerGitHub Enterprise <[email protected]>2024-05-02 17:50:27 +0200
commita4bf68b613a443538a54e77ff2863c88c1c8a86a (patch)
treea3a79b191d20e48f5f3ca810312e3eceaa13d9c5 /src
parentfix zero size attachment replies (#69) (diff)
downloadzen-a4bf68b613a443538a54e77ff2863c88c1c8a86a.tar.xz
zen-a4bf68b613a443538a54e77ff2863c88c1c8a86a.zip
added logic to change default HTTP server implementation when running on Wine (#71)
* added logic to change default HTTP server implementation when running on Wine * added log message to inform user about potential problems when running under Wine
Diffstat (limited to 'src')
-rw-r--r--src/zencore/include/zencore/windows.h2
-rw-r--r--src/zencore/windows.cpp13
-rw-r--r--src/zenserver/config.cpp11
-rw-r--r--src/zenserver/zenserver.cpp8
-rw-r--r--src/zenutil/zenserverprocess.cpp11
5 files changed, 39 insertions, 6 deletions
diff --git a/src/zencore/include/zencore/windows.h b/src/zencore/include/zencore/windows.h
index 14026fef1..b2b220f8f 100644
--- a/src/zencore/include/zencore/windows.h
+++ b/src/zencore/include/zencore/windows.h
@@ -412,5 +412,7 @@ private:
DWORD m_dwViewDesiredAccess;
};
+bool IsRunningOnWine();
+
} // namespace zen::windows
#endif
diff --git a/src/zencore/windows.cpp b/src/zencore/windows.cpp
index 76d8ab445..d02fcd35e 100644
--- a/src/zencore/windows.cpp
+++ b/src/zencore/windows.cpp
@@ -9,6 +9,19 @@
namespace zen::windows {
+bool
+IsRunningOnWine()
+{
+ HMODULE NtDll = GetModuleHandleA("ntdll.dll");
+
+ if (NtDll)
+ {
+ return !!GetProcAddress(NtDll, "wine_get_version");
+ }
+
+ return false;
+}
+
FileMapping::FileMapping(_In_ FileMapping& orig)
{
m_pData = NULL;
diff --git a/src/zenserver/config.cpp b/src/zenserver/config.cpp
index e33b6caf3..ce1b21926 100644
--- a/src/zenserver/config.cpp
+++ b/src/zenserver/config.cpp
@@ -35,6 +35,8 @@ ZEN_THIRD_PARTY_INCLUDES_END
#if ZEN_PLATFORM_WINDOWS
+# include <zencore/windows.h>
+
// Used for getting My Documents for default data directory
# include <ShlObj.h>
# pragma comment(lib, "shell32.lib")
@@ -550,10 +552,13 @@ ParseConfigFile(const std::filesystem::path& Path,
void
ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
{
-#if ZEN_WITH_HTTPSYS
- const char* DefaultHttp = "httpsys";
-#else
const char* DefaultHttp = "asio";
+
+#if ZEN_WITH_HTTPSYS
+ if (!zen::windows::IsRunningOnWine())
+ {
+ DefaultHttp = "httpsys";
+ }
#endif
// Note to those adding future options; std::filesystem::path-type options
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 89f376709..0909c26e9 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -608,6 +608,14 @@ ZenServer::Run()
}
ZEN_INFO(ZEN_APP_NAME " now running (pid: {})", GetCurrentProcessId());
+
+#if ZEN_PLATFORM_WINDOWS
+ if (zen::windows::IsRunningOnWine())
+ {
+ ZEN_INFO("detected Wine session - " ZEN_APP_NAME " is not formally tested on Wine and may therefore not work or perform well");
+ }
+#endif
+
#if ZEN_USE_SENTRY
ZEN_INFO("sentry crash handler {}", m_UseSentry ? "ENABLED" : "DISABLED");
if (m_UseSentry)
diff --git a/src/zenutil/zenserverprocess.cpp b/src/zenutil/zenserverprocess.cpp
index 26c72fc9b..a44ea4954 100644
--- a/src/zenutil/zenserverprocess.cpp
+++ b/src/zenutil/zenserverprocess.cpp
@@ -482,10 +482,15 @@ ZenServerEnvironment::InitializeForTest(std::filesystem::path ProgramBaseDir,
if (ServerClass.empty())
{
#if ZEN_WITH_HTTPSYS
- m_ServerClass = "httpsys"sv;
-#else
- m_ServerClass = "asio"sv;
+ if (!zen::windows::IsRunningOnWine())
+ {
+ m_ServerClass = "httpsys"sv;
+
+ return;
+ }
#endif
+
+ m_ServerClass = "asio"sv;
}
else
{