Fix the double-check locking[1] by defining the cls_initialized member to
volatile.

Greetings

Bert Wesarg

[1]: http://en.wikipedia.org/wiki/Double-checked_locking


---

 opal/class/opal_object.h |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff --quilt old/opal/class/opal_object.h new/opal/class/opal_object.h
--- old/opal/class/opal_object.h
+++ new/opal/class/opal_object.h
@@ -148,11 +148,11 @@ typedef void (*opal_destruct_t) (opal_ob
 struct opal_class_t {
     const char *cls_name;           /**< symbolic name for class */
     opal_class_t *cls_parent;       /**< parent class descriptor */
     opal_construct_t cls_construct; /**< class constructor */
     opal_destruct_t cls_destruct;   /**< class destructor */
-    int cls_initialized;            /**< is class initialized */
+    volatile int cls_initialized;   /**< is class initialized */
     int cls_depth;                  /**< depth of class hierarchy tree */
     opal_construct_t *cls_construct_array;
                                     /**< array of parent class constructors */
     opal_destruct_t *cls_destruct_array;
                                     /**< array of parent class destructors */

Reply via email to