From 56ac10f4aa85ef4c41f5fd3839c90b71087fe953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Wed, 29 Mar 2000 20:39:17 -0800 Subject: [PATCH] some DMALLOC (in)sanity Rev: src/main.c:1.85 Rev: src/threads.c:1.116 Rev: src/threads.h:1.78 --- src/main.c | 13 ++++++++++++- src/threads.c | 9 ++++++++- src/threads.h | 3 ++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 8df667cc1b..745c762ca9 100644 --- a/src/main.c +++ b/src/main.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: main.c,v 1.84 2000/03/28 08:10:53 hubbe Exp $"); +RCSID("$Id: main.c,v 1.85 2000/03/30 04:39:17 hubbe Exp $"); #include "fdlib.h" #include "backend.h" #include "module.h" @@ -618,6 +618,17 @@ void low_exit_main(void) { INT32 num,size,recount=0; fprintf(stderr,"Exited normally, counting bytes.\n"); + +#ifdef _REENTRANT + if(count_pike_threads()>1) + { + fprintf(stderr,"Byte counting aborted, because all threads have not exited properly.\n"); + verbose_debug_exit=0; + return; + } +#endif + + search_all_memheaders_for_references(); count_memory_in_arrays(&num, &size); diff --git a/src/threads.c b/src/threads.c index 9547806412..7ced389694 100644 --- a/src/threads.c +++ b/src/threads.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: threads.c,v 1.115 2000/03/25 20:58:30 hubbe Exp $"); +RCSID("$Id: threads.c,v 1.116 2000/03/30 04:39:17 hubbe Exp $"); int num_threads = 1; int threads_disabled = 0; @@ -378,6 +378,7 @@ void exit_interleave_mutex(IMUTEX_T *im) #define THREAD_TABLE_SIZE 127 /* Totally arbitrary prime */ static struct thread_state *thread_table_chains[THREAD_TABLE_SIZE]; +static int num_pike_threads=0; void thread_table_init(void) { @@ -421,6 +422,7 @@ void thread_table_insert(struct object *o) /* dumpmem("thread_table_insert",&s->id, sizeof(THREAD_T)); */ #endif mt_lock( & thread_table_lock ); + num_pike_threads++; if((s->hashlink = thread_table_chains[h]) != NULL) s->hashlink->backlink = &s->hashlink; thread_table_chains[h] = s; @@ -433,6 +435,7 @@ void thread_table_delete(struct object *o) struct thread_state *s = OBJ2THREAD(o); /* dumpmem("thread_table_delete",&s->id, sizeof(THREAD_T)); */ mt_lock( & thread_table_lock ); + num_pike_threads--; if(s->hashlink != NULL) s->hashlink->backlink = s->backlink; *(s->backlink) = s->hashlink; @@ -519,6 +522,10 @@ void f_all_threads(INT32 args) f_aggregate(sp-oldsp); } +int count_pike_threads(void) +{ + return num_pike_threads; +} static void check_threads(struct callback *cb, void *arg, void * arg2) { diff --git a/src/threads.h b/src/threads.h index e945250833..0c73c00f01 100644 --- a/src/threads.h +++ b/src/threads.h @@ -1,5 +1,5 @@ /* - * $Id: threads.h,v 1.77 2000/03/29 22:08:50 hubbe Exp $ + * $Id: threads.h,v 1.78 2000/03/30 04:39:17 hubbe Exp $ */ #ifndef THREADS_H #define THREADS_H @@ -556,6 +556,7 @@ void thread_table_delete(struct object *o); struct thread_state *thread_state_for_id(THREAD_T tid); struct object *thread_for_id(THREAD_T tid); void f_all_threads(INT32 args); +int count_pike_threads(void); TH_RETURN_TYPE new_thread_func(void * data); void f_thread_create(INT32 args); void f_thread_set_concurrency(INT32 args); -- GitLab