diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-03-09 20:51:24 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:56:50 -0500 |
commit | f829ca548b47b576fff20a12a42364c0d9142cbb (patch) | |
tree | de196d04277b3f60ab0b2617a4f7a2eccf63a829 /source4/smbd | |
parent | f710a30dc4cc03100492debf860d77c4ae868514 (diff) | |
download | samba-f829ca548b47b576fff20a12a42364c0d9142cbb.tar.gz samba-f829ca548b47b576fff20a12a42364c0d9142cbb.tar.bz2 samba-f829ca548b47b576fff20a12a42364c0d9142cbb.zip |
r14100: print out the title with the thread specific debug messages
metze
(This used to be commit defc9438d10d51f5f59a8ee69e6baf40b8d9278e)
Diffstat (limited to 'source4/smbd')
-rw-r--r-- | source4/smbd/process_thread.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c index 47ddd244c5..3f624bf871 100644 --- a/source4/smbd/process_thread.c +++ b/source4/smbd/process_thread.c @@ -39,6 +39,8 @@ #include "system/kerberos.h" #include "heimdal/lib/gssapi/gssapi_locl.h" +static pthread_key_t title_key; + struct new_conn_state { struct event_context *ev; struct socket_context *sock; @@ -191,6 +193,14 @@ static void thread_terminate(struct event_context *event_ctx, const char *reason /* called to set a title of a task or connection */ static void thread_set_title(struct event_context *ev, const char *title) { + char *old_title; + char *new_title; + + old_title = pthread_getspecific(title_key); + talloc_free(old_title); + + new_title = talloc_strdup(ev, title); + pthread_setspecific(title_key, new_title); } /* @@ -412,8 +422,10 @@ static uint32_t thread_get_task_id(void) static void thread_log_task_id(int fd) { char *s= NULL; - - asprintf(&s, "thread %u: ", (uint32_t)pthread_self()); + + asprintf(&s, "thread[%u][%s]:\n", + (uint32_t)pthread_self(), + (const char *)pthread_getspecific(title_key)); if (!s) return; write(fd, s, strlen(s)); free(s); @@ -425,7 +437,10 @@ catch serious errors static void thread_sig_fault(int sig) { DEBUG(0,("===============================================================\n")); - DEBUG(0,("TERMINAL ERROR: Recursive signal %d in thread %lu (%s)\n",sig,(unsigned long int)pthread_self(),SAMBA_VERSION_STRING)); + DEBUG(0,("TERMINAL ERROR: Recursive signal %d in thread [%u][%s] (%s)\n", + sig,(uint32_t)pthread_self(), + (const char *)pthread_getspecific(title_key), + SAMBA_VERSION_STRING)); DEBUG(0,("===============================================================\n")); exit(1); /* kill the whole server for now */ } @@ -459,7 +474,10 @@ static void thread_fault_handler(int sig) counter++; /* count number of faults that have occurred */ DEBUG(0,("===============================================================\n")); - DEBUG(0,("INTERNAL ERROR: Signal %d in thread %lu (%s)\n",sig,(unsigned long int)pthread_self(),SAMBA_VERSION_STRING)); + DEBUG(0,("INTERNAL ERROR: Signal %d in thread [%u] [%s] (%s)\n", + sig,(uint32_t)pthread_self(), + (const char *)pthread_getspecific(title_key), + SAMBA_VERSION_STRING)); DEBUG(0,("Please read the file BUGS.txt in the distribution\n")); DEBUG(0,("===============================================================\n")); #ifdef HAVE_BACKTRACE @@ -491,6 +509,9 @@ static void thread_model_init(struct event_context *event_context) ZERO_STRUCT(m_ops); ZERO_STRUCT(d_ops); + pthread_key_create(&title_key, NULL); + pthread_setspecific(title_key, talloc_strdup(event_context, "")); + /* register mutex/rwlock handlers */ m_ops.mutex_init = thread_mutex_init; m_ops.mutex_lock = thread_mutex_lock; |