mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-11-01 19:17:59 +00:00
Fixing ThreadNaming.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "Poco/Timespan.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#if defined(__sun) && defined(__SVR4)
|
||||
# if !defined(__EXTENSIONS__)
|
||||
# define __EXTENSIONS__
|
||||
@@ -70,6 +71,7 @@ void setThreadName(pthread_t thread, const std::string& threadName)
|
||||
#else
|
||||
if (pthread_setname_np(thread, threadName.c_str()) == ERANGE && threadName.size() > 15)
|
||||
{
|
||||
std::cout << "Calling OS thread name: " << threadName << std::endl;
|
||||
std::string truncName(threadName, 0, 7);
|
||||
truncName.append("~");
|
||||
truncName.append(threadName, threadName.size() - 7, 7);
|
||||
|
||||
@@ -130,6 +130,14 @@ void TCPServer::run()
|
||||
if(!_pDispatcher->params().getName().empty()) {
|
||||
std::cout << "Setting thread name: " << _pDispatcher->params().getName() << std::endl;
|
||||
Poco::Thread::current()->setName(_pDispatcher->params().getName());
|
||||
#ifdef __linux__
|
||||
Poco::Thread::current()->setName(_pDispatcher->params().getName());
|
||||
pthread_setname_np(pthread_self(), _pDispatcher->params().getName().c_str());
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
Poco::Thread::current()->setName(_pDispatcher->params().getName());
|
||||
pthread_setname_np(_pDispatcher->params().getName().c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
while (!_stopped)
|
||||
|
||||
@@ -104,6 +104,14 @@ void TCPServerDispatcher::run()
|
||||
if(!_pParams->getName().empty()) {
|
||||
std::cout << "Setting thread name: " << _pParams->getName() << std::endl;
|
||||
Poco::Thread::current()->setName(_pParams->getName());
|
||||
#ifdef __linux__
|
||||
Poco::Thread::current()->setName_pParams->getName());
|
||||
pthread_setname_np(pthread_self(), _pParams->getName().c_str());
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
Poco::Thread::current()->setName(_pParams->getName());
|
||||
pthread_setname_np(_pParams->getName().c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
for (;;)
|
||||
|
||||
Reference in New Issue
Block a user