BEGIN_DEBUG_EXCEPTION_HANDLER
+ porting::setThreadName("MeshUpdateThread");
+
while(!StopRequested())
{
QueuedMeshUpdate *q = m_queue_in.pop();
m_time_of_day_set = true;
u32 dr = m_env.getDayNightRatio();
- verbosestream<<"Client: time_of_day="<<time_of_day
+ infostream<<"Client: time_of_day="<<time_of_day
<<" time_speed="<<time_speed
<<" dr="<<dr<<std::endl;
}
PROFILE(std::stringstream ThreadIdentifier);
PROFILE(ThreadIdentifier << "ConnectionSend: [" << m_connection->getDesc() << "]");
+ porting::setThreadName("ConnectionSend");
+
/* if stop is requested don't stop immediately but try to send all */
/* packets first */
while(!StopRequested() || packetsQueued()) {
PROFILE(std::stringstream ThreadIdentifier);
PROFILE(ThreadIdentifier << "ConnectionReceive: [" << m_connection->getDesc() << "]");
+ porting::setThreadName("ConnectionReceive");
+
#ifdef DEBUG_CONNECTION_KBPS
u32 curtime = porting::getTimeMs();
u32 lasttime = curtime;
mapgen = emerge->mapgen[id];
enable_mapgen_debug_info = emerge->mapgen_debug_info;
+ porting::setThreadName("EmergeThread");
+
while (!StopRequested())
try {
if (!popBlockEmerge(&p, &flags)) {
log_register_thread("CurlFetchThread");
DSTACK(__FUNCTION_NAME);
+ porting::setThreadName("CurlFetchThread");
+
CurlHandlePool pool;
m_multi = curl_multi_init();
return 0;
}
+#if (defined(linux) || defined(__linux))
+
+#include <sys/prctl.h>
+
+inline void setThreadName(const char* name) {
+ prctl(PR_SET_NAME,name);
+}
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+/* BSD doesn't seem to support thread names. If you know about a way
+ * to add this feature please create a pull request.
+ * "setproctitle" doesn't work for threadnames.
+ */
+#define setThreadName(a)
+#elif defined(_WIN32)
+// threadnames are not supported on windows
+#define setThreadName(a)
+#else
+#warning "Unknown platform for setThreadName support, you wont have threadname support."
+#define setThreadName(a)
+#endif
} // namespace porting
snprintf(number,sizeof(number),"%d",m_threadnum);
log_register_thread(std::string("AsyncWorkerThread_") + number);
+ porting::setThreadName(
+ std::string(std::string("AsyncWorkTh_") + number).c_str());
+
/** prepare job lua environment **/
lua_newtable(m_LuaStack);
lua_setglobal(m_LuaStack, "engine");
ThreadStarted();
+ porting::setThreadName("ServerThread");
+
while(!StopRequested())
{
try{