mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-26 06:26:41 +00:00
Add support for several platforms to obtain the real thread ID.
Already had the pthread ID which is not the same. The most obvious enhancement is in the "core show threads" output. As stated in the utils header, if the platform isn't supported -1 is reported (instead of the process ID previously). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@298137 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -379,6 +379,7 @@ struct thread_list_t {
|
||||
AST_RWLIST_ENTRY(thread_list_t) list;
|
||||
char *name;
|
||||
pthread_t id;
|
||||
int lwp;
|
||||
};
|
||||
|
||||
static AST_RWLIST_HEAD_STATIC(thread_list, thread_list_t);
|
||||
@@ -390,6 +391,7 @@ void ast_register_thread(char *name)
|
||||
if (!new)
|
||||
return;
|
||||
new->id = pthread_self();
|
||||
new->lwp = ast_get_tid();
|
||||
new->name = name; /* steal the allocated memory for the thread name */
|
||||
AST_RWLIST_WRLOCK(&thread_list);
|
||||
AST_RWLIST_INSERT_HEAD(&thread_list, new, list);
|
||||
@@ -516,7 +518,7 @@ static char *handle_show_threads(struct ast_cli_entry *e, int cmd, struct ast_cl
|
||||
|
||||
AST_RWLIST_RDLOCK(&thread_list);
|
||||
AST_RWLIST_TRAVERSE(&thread_list, cur, list) {
|
||||
ast_cli(a->fd, "%p %s\n", (void *)cur->id, cur->name);
|
||||
ast_cli(a->fd, "%p %d %s\n", (void *)cur->id, cur->lwp, cur->name);
|
||||
count++;
|
||||
}
|
||||
AST_RWLIST_UNLOCK(&thread_list);
|
||||
|
||||
Reference in New Issue
Block a user