diff --git a/src/common/Thread.cpp b/src/common/Thread.cpp index 07cb4206..1ec45af1 100644 --- a/src/common/Thread.cpp +++ b/src/common/Thread.cpp @@ -13,7 +13,9 @@ * */ #include "Thread.h" +#include "Log.h" +#include #include #include @@ -46,7 +48,13 @@ bool Thread::run() return m_started; m_started = true; - return ::pthread_create(&m_thread, NULL, helper, this) == 0; + int err = ::pthread_create(&m_thread, NULL, helper, this); + if (err != 0) { + LogError(LOG_NET, "Error returned from pthread_create, err: %d", errno); + return false; + } + + return true; } /// diff --git a/src/fne/network/DiagNetwork.cpp b/src/fne/network/DiagNetwork.cpp index 5629f797..442467e1 100644 --- a/src/fne/network/DiagNetwork.cpp +++ b/src/fne/network/DiagNetwork.cpp @@ -95,7 +95,11 @@ void DiagNetwork::processNetwork() req->buffer = new uint8_t[length]; ::memcpy(req->buffer, buffer.get(), length); - ::pthread_create(&req->thread, NULL, threadedNetworkRx, req); + if (::pthread_create(&req->thread, NULL, threadedNetworkRx, req) != 0) { + LogError(LOG_NET, "Error returned from pthread_create, err: %d", errno); + delete req; + return; + } } } diff --git a/src/fne/network/FNENetwork.cpp b/src/fne/network/FNENetwork.cpp index 1bd7e3aa..73c597a3 100644 --- a/src/fne/network/FNENetwork.cpp +++ b/src/fne/network/FNENetwork.cpp @@ -26,6 +26,7 @@ using namespace network; using namespace network::fne; #include +#include #include // --------------------------------------------------------------------------- @@ -185,7 +186,11 @@ void FNENetwork::processNetwork() req->buffer = new uint8_t[length]; ::memcpy(req->buffer, buffer.get(), length); - ::pthread_create(&req->thread, NULL, threadedNetworkRx, req); + if (::pthread_create(&req->thread, NULL, threadedNetworkRx, req) != 0) { + LogError(LOG_NET, "Error returned from pthread_create, err: %d", errno); + delete req; + return; + } } else { // if the DMR handler has parrot frames to playback, playback a frame @@ -1028,7 +1033,12 @@ void FNENetwork::peerACLUpdate(uint32_t peerId) std::stringstream peerName; peerName << peerId << ":acl-update"; - ::pthread_create(&req->thread, NULL, threadedACLUpdate, req); + if (::pthread_create(&req->thread, NULL, threadedACLUpdate, req) != 0) { + LogError(LOG_NET, "Error returned from pthread_create, err: %d", errno); + delete req; + return; + } + if (pthread_kill(req->thread, 0) == 0) { ::pthread_setname_np(req->thread, peerName.str().c_str()); }