summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Hall <GMCH@hestia.halldom.com>2010-01-05 11:01:49 +0000
committerChris Hall <GMCH@hestia.halldom.com>2010-01-05 11:01:49 +0000
commitfc286f3e879afd0b5b6c2b889132622739138d66 (patch)
treecc423a21595af618006126a1a66bd7ef0ede305f
parent6746ef8cd683a5e0afa57a5fc90a28f533be68be (diff)
downloadquagga-fc286f3e879afd0b5b6c2b889132622739138d66.tar.bz2
quagga-fc286f3e879afd0b5b6c2b889132622739138d66.tar.xz
Add qpthreads_thread_created to lib/qpthreads
Flag indicates that at least one thread has been created. (To be used to ensure no surprises when daemonising !)
-rw-r--r--lib/qpthreads.c4
-rw-r--r--lib/qpthreads.h10
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/qpthreads.c b/lib/qpthreads.c
index e7b39f6d..58573087 100644
--- a/lib/qpthreads.c
+++ b/lib/qpthreads.c
@@ -254,7 +254,8 @@ enum qpthreads_enabled_state
static enum qpthreads_enabled_state qpthreads_enabled_state = qpt_state_unset ;
-int qpthreads_enabled_flag = 0 ;
+uint8_t qpthreads_enabled_flag = 0 ;
+uint8_t qpthreads_thread_created_flag = 0 ;
/* Function to set qpthreads_enabled, one way or the other.
*
@@ -437,6 +438,7 @@ qpt_thread_create(void* (*start)(void*), void* arg, qpt_thread_attr_t* attr)
int err ;
passert(qpthreads_enabled) ;
+ qpthreads_thread_created_flag = 1 ; /* and at least one thread created */
default_attr = (attr == NULL) ;
if (default_attr)
diff --git a/lib/qpthreads.h b/lib/qpthreads.h
index aaf8e5dd..4d71e12d 100644
--- a/lib/qpthreads.h
+++ b/lib/qpthreads.h
@@ -73,8 +73,11 @@
* qpthreads_enabled_freeze -- to test and freeze unset if not yet enabled
*/
-#define qpthreads_enabled ((const int)qpthreads_enabled_flag)
-#define qpthreads_enabled_freeze qpt_freeze_qpthreads_enabled()
+#define qpthreads_enabled ((const uint8_t)qpthreads_enabled_flag)
+#define qpthreads_enabled_freeze qpt_freeze_qpthreads_enabled()
+
+#define qpthreads_thread_created ((const uint8_t) \
+ qpthreads_thread_created_flag)
/*==============================================================================
* Data types
@@ -129,7 +132,8 @@ qpt_thread_join(qpt_thread_t thread_id) ;
/*==============================================================================
* qpthreads_enabled support -- NOT FOR PUBLIC CONSUMPTION !
*/
-private int qpthreads_enabled_flag ; /* DO NOT WRITE TO THIS PLEASE */
+private uint8_t qpthreads_enabled_flag ; /* DO NOT TOUCH THIS PLEASE */
+private uint8_t qpthreads_thread_created_flag ; /* DO NOT TOUCH THIS PLEASE */
private int
qpt_set_qpthreads_enabled(int how) ; /* qpthreads_enabled := how */