[Darshan-commits] [Git][darshan/darshan][master] cleanup darshan-core's locking code

Shane Snyder xgitlab at cels.anl.gov
Mon Jun 27 22:31:51 CDT 2016


Shane Snyder pushed to branch master at darshan / darshan


Commits:
301fd492 by Shane Snyder at 2016-06-27T22:29:23-05:00
cleanup darshan-core's locking code

some bugs were causing the regression tests to fail when using
LD_PRELOAD instrumentation method

- - - - -


1 changed file:

- darshan-runtime/lib/darshan-core.c


Changes:

=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -283,7 +283,19 @@ void darshan_core_initialize(int argc, char **argv)
             /* collect information about command line and mounted file systems */
             darshan_get_exe_and_mounts(init_core, argc, argv);
 
+            /* if darshan was successfully initialized, set the global pointer
+             * and bootstrap any modules with static initialization routines
+             */
+            DARSHAN_CORE_LOCK();
             darshan_core = init_core;
+            DARSHAN_CORE_UNLOCK();
+
+            i = 0;
+            while(mod_static_init_fns[i])
+            {
+                (*mod_static_init_fns[i])();
+                i++;
+            }
         }
     }
 
@@ -299,21 +311,6 @@ void darshan_core_initialize(int argc, char **argv)
         }
     }
 
-    /* if darshan was successfully initialized, set the global pointer and
-     * bootstrap any modules with static initialization routines
-     */
-    if(init_core)
-    {
-        darshan_core = init_core;
-
-        i = 0;
-        while(mod_static_init_fns[i])
-        {
-            (*mod_static_init_fns[i])();
-            i++;
-        }
-    }
-
     return;
 }
 
@@ -1801,13 +1798,14 @@ void darshan_core_register_module(
 
     *inout_mod_buf_size = 0;
 
-    if(!darshan_core || (mod_id >= DARSHAN_MAX_MODS))
-        return;
-
     DARSHAN_CORE_LOCK();
-    if(darshan_core->mod_array[mod_id])
+    if((darshan_core == NULL) ||
+       (mod_id >= DARSHAN_MAX_MODS) ||
+       (darshan_core->mod_array[mod_id] != NULL))
     {
-        /* if module is already registered just return */
+        /* just return if darshan not initialized, the module id
+         * is invalid, or if the module is already registered
+         */
         DARSHAN_CORE_UNLOCK();
         return;
     }
@@ -1860,9 +1858,11 @@ void darshan_core_unregister_module(
     darshan_module_id mod_id)
 {
     DARSHAN_CORE_LOCK();
-
     if(!darshan_core)
+    {
+        DARSHAN_CORE_UNLOCK();
         return;
+    }
 
     /* update darshan internal structures and header */
     free(darshan_core->mod_array[mod_id]);
@@ -1895,10 +1895,12 @@ void *darshan_core_register_record(
     void *rec_buf;
     int ret;
 
+    DARSHAN_CORE_LOCK();
     if(!darshan_core)
+    {
+        DARSHAN_CORE_UNLOCK();
         return(NULL);
-
-    DARSHAN_CORE_LOCK();
+    }
 
     /* check to see if this module has enough space to store a new record */
     if(darshan_core->mod_array[mod_id]->rec_mem_avail < rec_len)
@@ -1948,10 +1950,13 @@ void *darshan_core_register_record(
 
 double darshan_core_wtime()
 {
+    DARSHAN_CORE_LOCK();
     if(!darshan_core)
     {
+        DARSHAN_CORE_UNLOCK();
         return(0);
     }
+    DARSHAN_CORE_UNLOCK();
 
     return(DARSHAN_MPI_CALL(PMPI_Wtime)() - darshan_core->wtime_offset);
 }



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/301fd4921716685494a7365adec22e3bf7a9b15d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160627/88c36726/attachment-0001.html>


More information about the Darshan-commits mailing list