Skip to content

Commit a25a702

Browse files
committed
Fix NullReferenceException when releasing semaphore
1 parent 1f1457d commit a25a702

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Enyim.Caching/Memcached/MemcachedNode.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,10 @@ private void ReleaseSocket(PooledSocket socket)
647647
finally
648648
{
649649
// signal the event so if someone is waiting for it can reuse this item
650-
this.semaphore.Release();
650+
if (this.semaphore != null)
651+
{
652+
this.semaphore.Release();
653+
}
651654
}
652655
}
653656
else
@@ -664,7 +667,10 @@ private void ReleaseSocket(PooledSocket socket)
664667
{
665668
// make sure to signal the Acquire so it can create a new conenction
666669
// if the failure policy keeps the pool alive
667-
this.semaphore.Release();
670+
if (this.semaphore != null)
671+
{
672+
this.semaphore.Release();
673+
}
668674
}
669675
}
670676
}
@@ -678,7 +684,10 @@ private void ReleaseSocket(PooledSocket socket)
678684
}
679685
finally
680686
{
681-
this.semaphore.Release();
687+
if (this.semaphore != null)
688+
{
689+
this.semaphore.Release();
690+
}
682691
}
683692
}
684693
}

0 commit comments

Comments
 (0)