This time with attachment :)
Dear pjsip list
When debugging our multi-threaded Linux application that links
against PJSIP, it is quite annoying that the PJSIP threads don't
declare themselves. The threads inherit the application name,
which makes it difficult finding our own application's main thread.
Attached patch improves this by using pthread_setname_np() from
inside lib/pj/os_core_unix.c : pj_thread_create().
Could this patch be considered for inclusion in the next PJSIP release?
Many thanks,
Martin
--
diff -rupN pjproject-2.7.1.orig/pjlib/src/pj/os_core_unix.c pjproject-2.7.1/pjlib/src/pj/os_core_unix.c
--- pjproject-2.7.1.orig/pjlib/src/pj/os_core_unix.c 2016-04-13 08:24:48.000000000 +0200
+++ pjproject-2.7.1/pjlib/src/pj/os_core_unix.c 2018-05-02 18:09:06.160141727 +0200
@@ -638,6 +638,18 @@ PJ_DEF(pj_status_t) pj_thread_create( pj
*ptr_thread = rec;
+#if (defined(PJ_DEBUG) && PJ_DEBUG!=0)
+#if (defined(PJ_LINUX) && PJ_LINUX!=0) || defined(PJ_HAS_PTHREAD_SETNAME_NP)
+ {
+ char pthreadname[16];
+ pthreadname[0]='p';
+ pthreadname[1]='j';
+ strncpy(pthreadname+2, rec->obj_name, 14);
+ pthreadname[15]='\0';
+ pthread_setname_np(rec->thread, pthreadname);
+ }
+#endif
+#endif
PJ_LOG(6, (rec->obj_name, "Thread created"));
return PJ_SUCCESS;
#else
_______________________________________________
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org