From: cristy Date: Fri, 21 Dec 2012 02:42:29 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~4546 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa0ea940ed303df1e2a79db5eb00adc9adf582c1;p=imagemagick --- diff --git a/MagickCore/blob.c b/MagickCore/blob.c index b00e2b16d..00f7204d2 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -560,10 +560,7 @@ MagickExport MagickBooleanType CloseBlob(Image *image) case FileStream: { if (image->blob->synchronize != MagickFalse) - { - status=fflush(image->blob->file_info.file); - status=fsync(fileno(image->blob->file_info.file)); - } + status=fsync(fileno(image->blob->file_info.file)); status=fclose(image->blob->file_info.file); break; } @@ -3748,6 +3745,18 @@ MagickPrivate MagickBooleanType SetBlobExtent(Image *image, break; offset=SeekBlob(image,(MagickOffsetType) extent-1,SEEK_SET); count=fwrite((const unsigned char *) "",1,1,image->blob->file_info.file); +#if defined(MAGICKCORE_HAVE_POSIX_FALLOCATE) + if (image->blob->synchronize != MagickFalse) + { + int + status; + + status=posix_fallocate(fileno(image->blob->file_info.file),offset, + extent-offset); + if (status != 0) + return(MagickFalse); + } +#endif offset=SeekBlob(image,offset,SEEK_SET); if (count != (MagickOffsetType) 1) return(MagickFalse); @@ -3783,6 +3792,18 @@ MagickPrivate MagickBooleanType SetBlobExtent(Image *image, offset=SeekBlob(image,(MagickOffsetType) extent-1,SEEK_SET); count=fwrite((const unsigned char *) "",1,1, image->blob->file_info.file); +#if defined(MAGICKCORE_HAVE_POSIX_FALLOCATE) + if (image->blob->synchronize != MagickFalse) + { + int + status; + + status=posix_fallocate(fileno(image->blob->file_info.file),offset, + extent-offset); + if (status != 0) + return(MagickFalse); + } +#endif offset=SeekBlob(image,offset,SEEK_SET); if (count != (MagickOffsetType) 1) return(MagickTrue); diff --git a/MagickCore/cache-private.h b/MagickCore/cache-private.h index 26a38dc07..e5b6bf337 100644 --- a/MagickCore/cache-private.h +++ b/MagickCore/cache-private.h @@ -175,6 +175,7 @@ typedef struct _CacheInfo *random_info; MagickBooleanType + synchronize, debug; MagickThreadType diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 7433d8c6c..b09e79948 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -192,6 +192,9 @@ MagickPrivate Cache AcquirePixelCache(const size_t number_threads) CacheInfo *cache_info; + char + *synchronize; + cache_info=(CacheInfo *) AcquireQuantumMemory(1,sizeof(*cache_info)); if (cache_info == (CacheInfo *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); @@ -211,6 +214,12 @@ MagickPrivate Cache AcquirePixelCache(const size_t number_threads) cache_info->nexus_info=AcquirePixelCacheNexus(cache_info->number_threads); if (cache_info->nexus_info == (NexusInfo **) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); + synchronize=GetEnvironmentValue("MAGICK_SYNCHRONIZE"); + if (synchronize != (const char *) NULL) + { + cache_info->synchronize=IsStringTrue(synchronize); + synchronize=DestroyString(synchronize); + } cache_info->semaphore=AllocateSemaphoreInfo(); cache_info->reference_count=1; cache_info->file_semaphore=AllocateSemaphoreInfo(); @@ -3691,6 +3700,17 @@ static MagickBooleanType SetPixelCacheExtent(Image *image,MagickSizeType length) return(MagickTrue); extent=(MagickOffsetType) length-1; count=WritePixelCacheRegion(cache_info,extent,1,(const unsigned char *) ""); +#if defined(MAGICKCORE_HAVE_POSIX_FALLOCATE) + if (cache_info->synchronize != MagickFalse) + { + int + status; + + status=posix_fallocate(cache_info->file,offset+1,extent-offset); + if (status != 0) + return(MagickFalse); + } +#endif return(count != (MagickOffsetType) 1 ? MagickFalse : MagickTrue); } diff --git a/MagickCore/image.c b/MagickCore/image.c index 5d5637539..bbe60add1 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -1202,6 +1202,9 @@ MagickExport MagickBooleanType GetImageAlphaChannel(const Image *image) */ MagickExport void GetImageInfo(ImageInfo *image_info) { + char + *synchronize; + ExceptionInfo *exception; @@ -1217,8 +1220,12 @@ MagickExport void GetImageInfo(ImageInfo *image_info) image_info->quality=UndefinedCompressionQuality; image_info->antialias=MagickTrue; image_info->dither=MagickTrue; - image_info->synchronize=IsStringTrue(GetEnvironmentValue( - "MAGICK_SYNCHRONIZE")); + synchronize=GetEnvironmentValue("MAGICK_SYNCHRONIZE"); + if (synchronize != (const char *) NULL) + { + image_info->synchronize=IsStringTrue(synchronize); + synchronize=DestroyString(synchronize); + } exception=AcquireExceptionInfo(); (void) QueryColorCompliance(BackgroundColor,AllCompliance, &image_info->background_color,exception);