Skip to content
Browse files

Fixes the bucket selection for membase.

Note to self: never call stuff from a class's constructor when stuff depends on said class's virtual methods.
  • Loading branch information...
1 parent 0d3da75 commit 7613df2a9f1664e33c179982370f8fc389404694 @enyim enyim committed Sep 27, 2010
Showing with 10 additions and 3 deletions.
  1. +10 −3 Enyim.Caching/Memcached/MemcachedNode.cs
View
13 Enyim.Caching/Memcached/MemcachedNode.cs
@@ -24,6 +24,7 @@ public class MemcachedNode : IMemcachedNode
private IPEndPoint endPoint;
private ISocketPoolConfiguration config;
private InternalPoolImpl internalPoolImpl;
+ private bool isInitialized;
public MemcachedNode(IPEndPoint endpoint, ISocketPoolConfiguration socketPoolConfig)
{
@@ -105,6 +106,14 @@ public bool Ping()
/// <returns>An <see cref="T:PooledSocket"/> instance which is connected to the memcached server, or <value>null</value> if the pool is dead.</returns>
public PooledSocket Acquire()
{
+ if (!this.isInitialized)
+ lock (this.internalPoolImpl)
+ if (!this.isInitialized)
+ {
+ this.internalPoolImpl.InitPool();
+ this.isInitialized = true;
+ }
+
return this.internalPoolImpl.Acquire();
}
@@ -186,11 +195,9 @@ internal InternalPoolImpl(MemcachedNode ownerNode, ISocketPoolConfiguration conf
this.semaphore = new Semaphore(minItems, maxItems);
this.freeItems = new InterlockedQueue<PooledSocket>();
-
- this.InitPool();
}
- private void InitPool()
+ internal void InitPool()
{
try
{

0 comments on commit 7613df2

Please sign in to comment.
Something went wrong with that request. Please try again.