Browse Source

Better Semaphore fix

Former-commit-id: c679e15305cade71e0fec7d3db7f0eab41224741
pull/17/head
James South 12 years ago
parent
commit
b0d194c931
  1. 35
      src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs
  2. 2
      src/ImageProcessor/Imaging/Formats/GifFormat.cs
  3. 8
      src/TestWebsites/NET45/Test_Website_NET45/Web.config

35
src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs

@ -385,16 +385,14 @@ namespace ImageProcessor.Web.HttpModules
if (isRemote)
{
SemaphoreSlim semaphore = GetSemaphoreSlim(cachedPath);
#if NET45
await semaphore.WaitAsync();
#else
semaphore.Wait();
#endif
try
{
// This should not happen :(
if (semaphore != null)
{
semaphore.Wait();
}
Uri uri = new Uri(requestPath + "?" + urlParameters);
RemoteFile remoteFile = new RemoteFile(uri, false);
// Prevent response blocking.
@ -433,24 +431,19 @@ namespace ImageProcessor.Web.HttpModules
}
finally
{
// This should not happen :(
if (semaphore != null)
{
semaphore.Release();
}
semaphore.Release();
}
}
else
{
SemaphoreSlim semaphore = GetSemaphoreSlim(cachedPath);
#if NET45
await semaphore.WaitAsync();
#else
semaphore.Wait();
#endif
try
{
// This should not happen :(
if (semaphore != null)
{
semaphore.Wait();
}
// Check to see if the file exists.
// ReSharper disable once AssignNullToNotNullAttribute
FileInfo fileInfo = new FileInfo(requestPath);
@ -476,11 +469,7 @@ namespace ImageProcessor.Web.HttpModules
}
finally
{
// This should not happen :(
if (semaphore != null)
{
semaphore.Release();
}
semaphore.Release();
}
}
}

2
src/ImageProcessor/Imaging/Formats/GifFormat.cs

@ -86,7 +86,7 @@ namespace ImageProcessor.Imaging.Formats
foreach (GifFrame frame in info.GifFrames)
{
factory.Image = frame.Image;
frame.Image = quantizer.Quantize(processor.Invoke(factory));
frame.Image = quantizer.Quantize(processor.Invoke(factory));
encoder.AddFrame(frame);
}
}

8
src/TestWebsites/NET45/Test_Website_NET45/Web.config

@ -6,17 +6,17 @@
<configuration>
<configSections>
<!--<sectionGroup name="imageProcessor">
<sectionGroup name="imageProcessor">
<section name="security" requirePermission="false" type="ImageProcessor.Web.Configuration.ImageSecuritySection, ImageProcessor.Web"/>
<section name="processing" requirePermission="false" type="ImageProcessor.Web.Configuration.ImageProcessingSection, ImageProcessor.Web"/>
<section name="cache" requirePermission="false" type="ImageProcessor.Web.Configuration.ImageCacheSection, ImageProcessor.Web"/>
</sectionGroup>-->
</sectionGroup>
</configSections>
<!--<imageProcessor >
<imageProcessor >
<security configSource="config\imageprocessor\security.config"/>
<cache configSource="config\imageprocessor\cache.config"/>
<processing configSource="config\imageprocessor\processing.config"/>
</imageProcessor>-->
</imageProcessor>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />

Loading…
Cancel
Save