Skip to content

Commit

Permalink
Release dead connections so the pool can create new ones when the fai…
Browse files Browse the repository at this point in the history
…lure policy keeps the socket pool alive.
  • Loading branch information
enyim committed Aug 26, 2011
1 parent 9cfb664 commit 4a451b0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Enyim.Caching/Memcached/MemcachedNode.cs
Expand Up @@ -332,6 +332,13 @@ public PooledSocket Acquire()
catch (Exception e)
{
log.Error("Failed to create socket. " + this.endPoint, e);

// eventhough this item failed the failure policy may keep the pool alive
// so we need to make sure to release the semaphore, so new connections can be
// acquired or created (otherwise dead conenctions would "fill up" the pool
// while the FP pretends that the pool is healthy)
semaphore.Release();

this.MarkAsDead();

return null;
Expand Down Expand Up @@ -394,6 +401,10 @@ private void ReleaseSocket(PooledSocket socket)

// mark ourselves as not working for a while
this.MarkAsDead();

// make sure to signal the Acquire so it can create a new conenction
// if the failure policy keeps the pool alive
this.semaphore.Release();
}
}
else
Expand Down

0 comments on commit 4a451b0

Please sign in to comment.