From 33d6c919d7c56f57f6f11a98dbff857311c451f1 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Tue, 18 Mar 2025 09:17:23 -0400 Subject: [PATCH] runAsThread should not automatically cleanup the passed thread_t, this should be done by the caller; --- src/common/Thread.cpp | 1 - src/common/Thread.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/Thread.cpp b/src/common/Thread.cpp index 93e9cc96..3dfcad36 100644 --- a/src/common/Thread.cpp +++ b/src/common/Thread.cpp @@ -128,7 +128,6 @@ bool Thread::runAsThread(void* obj, void *(*startRoutine)(void *), thread_t* thr #else if (::pthread_create(&thread->thread, NULL, startRoutine, thread) != 0) { LogError(LOG_NET, "Error returned from pthread_create, err: %d", errno); - delete thread; return false; } #endif // defined(_WIN32) diff --git a/src/common/Thread.h b/src/common/Thread.h index 03ed8a3e..e101f445 100644 --- a/src/common/Thread.h +++ b/src/common/Thread.h @@ -100,6 +100,8 @@ public: /** * @brief Executes the specified start routine to run as a thread. + * On POSIX, if the thread fails to spawn for any reason, the caller should clean up the passed thread_t + * argument. * @param obj Instance of a object to pass to the threaded function. * @param startRoutine Represents the function that executes on a thread. * @param[out] thread Instance of the thread data.