Skip to content

Commit c20ab14

Browse files
committed
Don't kill us if we're the thread that's retrying to Start() after a failure.
1 parent 7e1e8ca commit c20ab14

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/ServiceStack.Redis/Messaging/RedisMqServer.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,30 @@ public void Start()
237237

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

240-
KillBgThreadIfExists();
240+
StartWorkerThreads();
241241

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

249-
StartWorkerThreads();
247+
bgThread = new Thread(RunLoop)
248+
{
249+
IsBackground = true,
250+
Name = "Redis MQ Server " + Interlocked.Increment(ref bgThreadCount)
251+
};
252+
bgThread.Start();
253+
Log.Debug("Started Background Thread: " + bgThread.Name);
254+
}
255+
else
256+
{
257+
Log.Debug("Retrying RunLoop() on Thread: " + bgThread.Name);
258+
RunLoop();
259+
}
250260
}
251261
catch (Exception ex)
252262
{
263+
ex.Message.Print();
253264
if (this.ErrorHandler != null) this.ErrorHandler(ex);
254265
}
255266
}

0 commit comments

Comments
 (0)