]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 13 May 2010 01:54:31 +0000 (01:54 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 13 May 2010 01:54:31 +0000 (01:54 +0000)
magick/magick.c

index c94ae65b8f0916cd5e6f287bfc941eb4889b1412..ac568d5c34bd95945633406827ffc1ff4ff91785 100644 (file)
@@ -67,6 +67,7 @@
 #include "magick/resource_.h"
 #include "magick/policy.h"
 #include "magick/semaphore.h"
+#include "magick/semaphore-private.h"
 #include "magick/signature-private.h"
 #include "magick/splay-tree.h"
 #include "magick/string_.h"
@@ -112,7 +113,8 @@ static SplayTreeInfo
   *magick_list = (SplayTreeInfo *) NULL;
 
 static volatile MagickBooleanType
-  instantiate_magick = MagickFalse;  /* double-checked locking pattern */
+  instantiate_magick = MagickFalse,
+  instantiate_magickcore = MagickFalse;
 \f
 /*
   Forward declarations.
@@ -1208,6 +1210,12 @@ MagickExport void MagickCoreGenesis(const char *path,
   /*
     Initialize the Magick environment.
   */
+  LockMagickMutex();
+  if (instantiate_magickcore != MagickFalse)
+    {
+      UnlockMagickMutex();
+      return;
+    }
   (void) SemaphoreComponentGenesis();
   (void) LogComponentGenesis();
   (void) LocaleComponentGenesis();
@@ -1306,6 +1314,8 @@ MagickExport void MagickCoreGenesis(const char *path,
 #if defined(MAGICKCORE_X11_DELEGATE)
   (void) XComponentGenesis();
 #endif
+  instantiate_magickcore=MagickTrue;
+  UnlockMagickMutex();
 }
 \f
 /*
@@ -1328,6 +1338,12 @@ MagickExport void MagickCoreGenesis(const char *path,
 */
 MagickExport void MagickCoreTerminus(void)
 {
+  LockMagickMutex();
+  if (instantiate_magickcore == MagickFalse)
+    {
+      UnlockMagickMutex();
+      return;
+    }
 #if defined(MAGICKCORE_X11_DELEGATE)
   XComponentTerminus();
 #endif
@@ -1357,7 +1373,8 @@ MagickExport void MagickCoreTerminus(void)
   LocaleComponentTerminus();
   LogComponentTerminus();
   SemaphoreComponentTerminus();
-  instantiate_magick=MagickFalse;
+  instantiate_magickcore=MagickFalse;
+  UnlockMagickMutex();
 }
 \f
 /*