fix linux

This commit is contained in:
simplxs 2024-06-29 20:30:32 +08:00
parent 1a682ff12d
commit 260223e70b
No known key found for this signature in database
GPG Key ID: 1A3833A46D84A08C
2 changed files with 50 additions and 39 deletions

View File

@ -2,48 +2,52 @@
Server *server = nullptr; Server *server = nullptr;
void init()
{
try
{
std::string ip = "0.0.0.0";
int port = 8080;
printf("Start Init server\n");
server = new Server();
server->Init();
printf("Start Init sign\n");
std::thread([=] { // Cannot use '&' capture!!!!! will cause crash
for (int i = 0; i < 10; i++)
{
try
{
if (Sign::Init())
{
if (!server->Run(ip, port))
printf("Server run failed\n");
break;
}
}
catch (const std::exception &e)
{
printf("Init failed: %s\n", e.what());
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}
})
.detach();
}
catch (const std::exception &e)
{
printf("Init failed: %s\n", e.what());
}
}
#if defined(_WIN_PLATFORM_)
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{ {
switch (fdwReason) switch (fdwReason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
{ init();
try
{
std::string ip = "0.0.0.0";
int port = 8080;
printf("Start Init server\n");
server = new Server();
server->Init();
printf("Start Init sign\n");
std::thread([=] { // Cannot use & capture!!!!! will cause crash
for (int i = 0; i < 10; i++)
{
try
{
if (Sign::Init())
{
if (!server->Run(ip, port))
printf("Server run failed\n");
break;
}
}
catch (const std::exception &e)
{
printf("Init failed: %s\n", e.what());
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}
})
.detach();
}
catch (const std::exception &e)
{
printf("Init failed: %s\n", e.what());
}
break; break;
}
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
break; break;
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
@ -58,3 +62,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
} }
return TRUE; return TRUE;
} }
#elif defined(_MAC_PLATFORM_) || defined(_LINUX_PLATFORM_)
int main()
{
init();
}
#endif

View File

@ -50,12 +50,13 @@ std::map<std::string, uint64_t> addrMap = {
{"6.9.20-17153", 0x1c73dd0}}; {"6.9.20-17153", 0x1c73dd0}};
#endif #endif
#elif defined(_LINUX_PLATFORM_) #elif defined(_LINUX_PLATFORM_)
#define CURRENT_VERSION "3.2.7-23361" #define CURRENT_VERSION "3.2.9-24815"
#if defined(_X64_ARCH_) #if defined(_X64_ARCH_)
std::map<std::string, uint64_t> addrMap = { std::map<std::string, uint64_t> addrMap = {
{"3.1.2-12912", 0x33C38E0}, {"3.1.2-12912", 0x33C38E0},
{"3.1.2-13107", 0x33C3920}, {"3.1.2-13107", 0x33C3920},
{"3.2.7-23361", 0x4C93C57}}; {"3.2.7-23361", 0x4C93C57},
{"3.2.9-24815", 0x4E5D3B7}};
#elif defined(_ARM64_ARCH_) #elif defined(_ARM64_ARCH_)
std::map<std::string, uint64_t> addrMap = { std::map<std::string, uint64_t> addrMap = {
{"3.2.7-23361", 0x351EC98}}; {"3.2.7-23361", 0x351EC98}};