From 5e8a8ddba1aa122f073baa5a06ebfe37e8a2bcf2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 1 Jan 2019 00:47:54 +1100 Subject: [PATCH] Fix resume being broken and getting corrupted, fix closed client instances spawned by launcher showing as zombie/defunct processes --- src/LScreens.c | 22 ++++++++++++++-------- src/Platform.c | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/LScreens.c b/src/LScreens.c index 582e14102..f5b96346c 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -658,15 +658,21 @@ static struct MainScreen { struct ResumeInfo { String User, Ip, Port, Server, Mppass; - char _mppassBuffer[STRING_SIZE]; + char _userBuffer[STRING_SIZE], _serverBuffer[STRING_SIZE]; + char _ipBuffer[16], _portBuffer[16], _mppassBuffer[STRING_SIZE]; bool Valid; }; -CC_NOINLINE static void MainScreen_UNSAFE_GetResume(struct ResumeInfo* info, bool full) { - Options_UNSAFE_Get("launcher-server", &info->Server); - Options_UNSAFE_Get("launcher-username", &info->User); - Options_UNSAFE_Get("launcher-ip", &info->Ip); - Options_UNSAFE_Get("launcher-port", &info->Port); +CC_NOINLINE static void MainScreen_GetResume(struct ResumeInfo* info, bool full) { + String_InitArray(info->Server, info->_serverBuffer); + Options_Get("launcher-server", &info->Server, NULL); + String_InitArray(info->User, info->_userBuffer); + Options_Get("launcher-username", &info->User, NULL); + + String_InitArray(info->Ip, info->_ipBuffer); + Options_Get("launcher-ip", &info->Ip, NULL); + String_InitArray(info->Port, info->_portBuffer); + Options_Get("launcher-port", &info->Port, NULL); if (!full) return; String_InitArray(info->Mppass, info->_mppassBuffer); @@ -723,7 +729,7 @@ static void MainScreen_Login(void* w, int x, int y) { static void MainScreen_Resume(void* w, int x, int y) { struct ResumeInfo info; - MainScreen_UNSAFE_GetResume(&info, true); + MainScreen_GetResume(&info, true); if (!info.Valid) return; Launcher_StartGame(&info.User, &info.Mppass, &info.Ip, &info.Port, &info.Server); @@ -800,7 +806,7 @@ static void MainScreen_HoverWidget(struct LScreen* s_, struct LWidget* w) { struct ResumeInfo info; if (s->SigningIn || w != (struct LWidget*)&s->BtnResume) return; - MainScreen_UNSAFE_GetResume(&info, false); + MainScreen_GetResume(&info, false); if (!info.User.length) return; String_InitArray(str, strBuffer); diff --git a/src/Platform.c b/src/Platform.c index 27f8fc1da..7257ae9e7 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -72,6 +72,7 @@ const ReturnCode ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK; #include #include #include +#include #define Socket__Error() errno char* Platform_NewLine = "\n"; @@ -1911,6 +1912,7 @@ int Platform_ConvertString(void* data, const String* src) { } void Platform_Init(void) { + signal(SIGCHLD, SIG_IGN); Platform_InitDisplay(); Platform_InitStopwatch(); pthread_mutex_init(&event_mutex, NULL);