summaryrefslogtreecommitdiff
path: root/source4/smbd/process_thread.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-12-04 11:01:58 +0000
committerAndrew Tridgell <tridge@samba.org>2003-12-04 11:01:58 +0000
commit42c6a2548a658a198f128cdce36b9fcf869c33c8 (patch)
tree45addf4f9e93d6d12b4f4d6fa44b8f4a9e16119d /source4/smbd/process_thread.c
parent2e5ae6f0650962db86fcdb1290f9a7c8b07b1410 (diff)
downloadsamba-42c6a2548a658a198f128cdce36b9fcf869c33c8.tar.gz
samba-42c6a2548a658a198f128cdce36b9fcf869c33c8.tar.bz2
samba-42c6a2548a658a198f128cdce36b9fcf869c33c8.zip
merged more updates from Jim Myers
(This used to be commit 03bf30659640d684073f92d64da6e911edb65a73)
Diffstat (limited to 'source4/smbd/process_thread.c')
-rw-r--r--source4/smbd/process_thread.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c
index 346c362c5a..9c312e0d1f 100644
--- a/source4/smbd/process_thread.c
+++ b/source4/smbd/process_thread.c
@@ -21,7 +21,9 @@
#include "includes.h"
#include "pthread.h"
+#ifdef HAVE_BACKTRACE
#include "execinfo.h"
+#endif
static void *connection_thread(void *thread_parm)
{
@@ -267,12 +269,14 @@ static void thread_log_suspicious_usage(const char* from, const char* info)
char **bt_symbols;
DEBUG(1,("log_suspicious_usage: from %s info='%s'\n", from, info));
+#ifdef HAVE_BACKTRACE
num_addresses = backtrace(addresses, 8);
bt_symbols = backtrace_symbols(addresses, num_addresses);
for (i=0; i<num_addresses; i++) {
DEBUG(1,("log_suspicious_usage: %s%s\n", DEBUGTAB(1), bt_symbols[i]));
}
free(bt_symbols);
+#endif
}
/*****************************************************************
@@ -286,19 +290,29 @@ static void thread_print_suspicious_usage(const char* from, const char* info)
char **bt_symbols;
printf("log_suspicious_usage: from %s info='%s'\n", from, info);
+#ifdef HAVE_BACKTRACE
num_addresses = backtrace(addresses, 8);
bt_symbols = backtrace_symbols(addresses, num_addresses);
for (i=0; i<num_addresses; i++) {
printf("log_suspicious_usage: %s%s\n", DEBUGTAB(1), bt_symbols[i]);
}
free(bt_symbols);
+#endif
}
-uint32 thread_get_task_id(void)
+static uint32 thread_get_task_id(void)
{
return (uint32)pthread_self();
}
+static void thread_log_task_id(int fd)
+{
+ char *s;
+
+ asprintf(&s, "thread %u: ", (uint32)pthread_self());
+ write(fd, s, strlen(s));
+ free(s);
+}
/****************************************************************************
catch serious errors
****************************************************************************/
@@ -342,13 +356,14 @@ static void thread_fault_handler(int sig)
DEBUG(0,("INTERNAL ERROR: Signal %d in thread %lu (%s)\n",sig,(unsigned long int)pthread_self(),SAMBA_VERSION));
DEBUG(0,("Please read the file BUGS.txt in the distribution\n"));
DEBUG(0,("===============================================================\n"));
-
+#ifdef HAVE_BACKTRACE
num_addresses = backtrace(addresses, 10);
bt_symbols = backtrace_symbols(addresses, num_addresses);
for (i=0; i<num_addresses; i++) {
DEBUG(9,("fault_report: %s\n", bt_symbols[i]));
}
free(bt_symbols);
+#endif
pthread_exit(NULL); /* terminate failing thread only */
}
@@ -384,6 +399,7 @@ static void model_startup(void)
d_ops.log_suspicious_usage = thread_log_suspicious_usage;
d_ops.print_suspicious_usage = thread_print_suspicious_usage;
d_ops.get_task_id = thread_get_task_id;
+ d_ops.log_task_id = thread_log_task_id;
register_debug_handlers("thread", &d_ops);
}