Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Log constructor: guard against multiple initializations.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 30 Mar 2012 12:10:01 +0000 (14:10 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 30 Mar 2012 12:28:56 +0000 (14:28 +0200)
include/xbt/log.h

index a398c40..8a40ef1 100644 (file)
@@ -140,9 +140,11 @@ typedef enum {
   void _XBT_LOGV_CTOR(catName)(void)                                    \
   {                                                                     \
     XBT_LOG_EXTERNAL_CATEGORY(catName);                                 \
-    /* Note: _XBT_LOGV(parent) should be already declared here. */      \
-    XBT_LOG_CONNECT_PARENT(catName, parent);                            \
-    _xbt_log_cat_init(&_XBT_LOGV(catName), xbt_log_priority_uninitialized); \
+    if (!_XBT_LOGV(catName).initialized) {                              \
+      /* Note: _XBT_LOGV(parent) should be already declared here. */    \
+      XBT_LOG_CONNECT_PARENT(catName, parent);                          \
+      _xbt_log_cat_init(&_XBT_LOGV(catName), xbt_log_priority_uninitialized); \
+    }                                                                   \
   }                                                                     \
   XBT_EXPORT_NO_IMPORT(s_xbt_log_category_t) _XBT_LOGV(catName) = {     \
     _XBT_LOG_PARENT_INITIALIZER(parent),                                \