diff --git a/magick/constitute.c b/magick/constitute.c
index 96283b4..12f74f7 100644
--- a/magick/constitute.c
+++ b/magick/constitute.c
@@ -94,8 +94,8 @@
*/
MagickExport MagickBooleanType ConstituteComponentGenesis(void)
{
- AcquireSemaphoreInfo(&constitute_semaphore);
- RelinquishSemaphoreInfo(constitute_semaphore);
+ assert(constitute_semaphore == (SemaphoreInfo *) NULL);
+ constitute_semaphore=AllocateSemaphoreInfo();
return(MagickTrue);
}
@@ -119,8 +119,9 @@
*/
MagickExport void ConstituteComponentTerminus(void)
{
- if (constitute_semaphore != (SemaphoreInfo *) NULL)
- DestroySemaphoreInfo(&constitute_semaphore);
+ if (constitute_semaphore == (SemaphoreInfo *) NULL)
+ AcquireSemaphoreInfo(&constitute_semaphore);
+ DestroySemaphoreInfo(&constitute_semaphore);
}
/*
@@ -514,10 +515,13 @@
{
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & DecoderThreadSupport) == 0)
- AcquireSemaphoreInfo(&constitute_semaphore);
+ {
+ AcquireSemaphoreInfo(&constitute_semaphore);
+ LockSemaphoreInfo(constitute_semaphore);
+ }
image=GetImageDecoder(magick_info)(read_info,exception);
if ((thread_support & DecoderThreadSupport) == 0)
- RelinquishSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(constitute_semaphore);
}
else
{
@@ -546,11 +550,14 @@
MaxTextExtent);
*read_info->filename='\0';
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- AcquireSemaphoreInfo(&constitute_semaphore);
+ {
+ AcquireSemaphoreInfo(&constitute_semaphore);
+ LockSemaphoreInfo(constitute_semaphore);
+ }
(void) InvokeDelegate(read_info,image,read_info->magick,(char *) NULL,
exception);
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- RelinquishSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(constitute_semaphore);
image=DestroyImageList(image);
read_info->temporary=MagickTrue;
(void) SetImageInfo(read_info,MagickFalse,exception);
@@ -570,10 +577,13 @@
}
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & DecoderThreadSupport) == 0)
- AcquireSemaphoreInfo(&constitute_semaphore);
+ {
+ AcquireSemaphoreInfo(&constitute_semaphore);
+ LockSemaphoreInfo(constitute_semaphore);
+ }
image=(Image *) (GetImageDecoder(magick_info))(read_info,exception);
if ((thread_support & DecoderThreadSupport) == 0)
- RelinquishSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(constitute_semaphore);
}
if (read_info->temporary != MagickFalse)
{
@@ -1099,10 +1109,13 @@
*/
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & EncoderThreadSupport) == 0)
- AcquireSemaphoreInfo(&constitute_semaphore);
+ {
+ AcquireSemaphoreInfo(&constitute_semaphore);
+ LockSemaphoreInfo(constitute_semaphore);
+ }
status=GetImageEncoder(magick_info)(write_info,image);
if ((thread_support & EncoderThreadSupport) == 0)
- RelinquishSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(constitute_semaphore);
}
else
{
@@ -1115,11 +1128,14 @@
*/
*write_info->filename='\0';
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- AcquireSemaphoreInfo(&constitute_semaphore);
+ {
+ AcquireSemaphoreInfo(&constitute_semaphore);
+ LockSemaphoreInfo(constitute_semaphore);
+ }
status=InvokeDelegate(write_info,image,(char *) NULL,
write_info->magick,&image->exception);
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- RelinquishSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(constitute_semaphore);
(void) CopyMagickString(image->filename,filename,MaxTextExtent);
}
else
@@ -1146,10 +1162,13 @@
*/
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & EncoderThreadSupport) == 0)
- AcquireSemaphoreInfo(&constitute_semaphore);
+ {
+ AcquireSemaphoreInfo(&constitute_semaphore);
+ LockSemaphoreInfo(constitute_semaphore);
+ }
status=GetImageEncoder(magick_info)(write_info,image);
if ((thread_support & EncoderThreadSupport) == 0)
- RelinquishSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(constitute_semaphore);
}
}
}