Skip to content

Commit

Permalink
Don't kill us if we're the thread that's retrying to Start() after a …
Browse files Browse the repository at this point in the history
…failure.
  • Loading branch information
mythz committed Jun 13, 2013
1 parent 7e1e8ca commit c20ab14
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/ServiceStack.Redis/Messaging/RedisMqServer.cs
Expand Up @@ -237,19 +237,30 @@ public void Start()

SleepBackOffMultiplier(Interlocked.CompareExchange(ref noOfContinuousErrors, 0, 0));

KillBgThreadIfExists();
StartWorkerThreads();

bgThread = new Thread(RunLoop) {
IsBackground = true,
Name = "Redis MQ Server " + Interlocked.Increment(ref bgThreadCount)
};
bgThread.Start();
Log.Debug("Started Background Thread: " + bgThread.Name);
//Don't kill us if we're the thread that's retrying to Start() after a failure.
if (bgThread != Thread.CurrentThread)
{
KillBgThreadIfExists();

StartWorkerThreads();
bgThread = new Thread(RunLoop)
{
IsBackground = true,
Name = "Redis MQ Server " + Interlocked.Increment(ref bgThreadCount)
};
bgThread.Start();
Log.Debug("Started Background Thread: " + bgThread.Name);
}
else
{
Log.Debug("Retrying RunLoop() on Thread: " + bgThread.Name);
RunLoop();
}
}
catch (Exception ex)
{
ex.Message.Print();
if (this.ErrorHandler != null) this.ErrorHandler(ex);
}
}
Expand Down

0 comments on commit c20ab14

Please sign in to comment.