From 4996e64deb1347f2c10284a3ac1a41780fe77fda Mon Sep 17 00:00:00 2001 From: Leonid Pavel Date: Thu, 2 Nov 2023 19:54:41 +0000 Subject: [PATCH] LogServer: fix listening after resuming the system With this the log server works after suspending and resuming the console, where previously it wouldn't send any data --- kernel/src/Plugins/LogServer/LogManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/src/Plugins/LogServer/LogManager.cpp b/kernel/src/Plugins/LogServer/LogManager.cpp index fe5a1dec..1ef8c04e 100644 --- a/kernel/src/Plugins/LogServer/LogManager.cpp +++ b/kernel/src/Plugins/LogServer/LogManager.cpp @@ -87,6 +87,9 @@ bool LogManager::Startup() WriteLog(LL_Error, "here"); + // Make sure nothing's running + Teardown(); + auto kthread_add = (int(*)(void(*func)(void*), void* arg, struct proc* procptr, struct thread** tdptr, int flags, int pages, const char* fmt, ...))kdlsym(kthread_add); WriteLog(LL_Error, "m_Socket (%d) &m_Socket (%p) s_MainThread (%p)", m_Socket, &m_Socket, s_MainThread); @@ -133,6 +136,9 @@ bool LogManager::Startup() return false; } + // Set our running state + m_Running = true; + // Create the new server processing thread, 8MiB stack s_Ret = kthread_add(LogManager::ServerThread, this, Mira::Framework::GetFramework()->GetInitParams()->process, reinterpret_cast(&m_Thread), 0, 200, "LogServer"); WriteLog(LL_Debug, "logserver kthread_add returned (%d).", s_Ret); @@ -190,9 +196,6 @@ void LogManager::ServerThread(void* p_UserArgs) return; } - // Set our running state - s_LogManager->m_Running = true; - // Create our timeout struct timeval s_Timeout { @@ -274,7 +277,7 @@ void LogManager::ServerThread(void* p_UserArgs) cleanup: // Disconnects all clients, set running to false WriteLog(LL_Debug, "logserver tearing down"); - s_LogManager->Teardown(); + kclose_t(s_LogDevice, s_MainThread); WriteLog(LL_Debug, "logserver exiting cleanly"); kthread_exit();