private void Worker(object state)
{
if (log.IsDebugEnabled) log.Debug("Started working.");
while (this.stopCounter == 0)
{
if (this.client == null)
this.client = this.CreateClient();
// false means that the url was not responding or failed while reading
this.statusPool = this.urls.ToDictionary(u => u, u => true);
this.urlIndex = 0;
// this will quit when all nodes go down or we're stopped externally
this.ProcessPool();
// sockIOPool fail
if (this.stopCounter == 0)
{
if (log.IsWarnEnabled) log.Warn("All nodes are dead, sleeping for a while.");
this.Trigger(null);
this.SleepUntil(this.DeadTimeout);
// recreate the memcachedClient after failure
this.CleanupRequests();
if (this.client != null)
{
this.client.Dispose();
this.client = null;
}
}
}
}