Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit aef445a

Browse files
committed
Fix RedisPubSubServer blocks running thread
1 parent 4dd6364 commit aef445a

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/ServiceStack.Redis/RedisPubSubServer.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ public class RedisPubSubServer : IRedisPubSubServer
4141
private int noOfContinuousErrors = 0;
4242
private string lastExMsg = null;
4343
private int status;
44-
#if !NETSTANDARD1_3
4544
private Thread bgThread; //Subscription controller thread
46-
#endif
4745
private long bgThreadCount = 0;
4846

4947
private const int NO = 0;
@@ -111,9 +109,6 @@ public IRedisPubSubServer Start()
111109
if (OnStart != null)
112110
OnStart();
113111

114-
#if NETSTANDARD1_3
115-
RunLoop();
116-
#else
117112
//Don't kill us if we're the thread that's retrying to Start() after a failure.
118113
if (bgThread != Thread.CurrentThread)
119114
{
@@ -134,7 +129,6 @@ public IRedisPubSubServer Start()
134129
Log.Debug("Retrying RunLoop() on Thread: " + bgThread.Name);
135130
RunLoop();
136131
}
137-
#endif
138132
}
139133
catch (Exception ex)
140134
{
@@ -438,14 +432,14 @@ public void Restart()
438432
Stop(shouldRestart:true);
439433
}
440434

441-
#if !NETSTANDARD1_3
442435
private void KillBgThreadIfExists()
443436
{
444437
if (bgThread != null && bgThread.IsAlive)
445438
{
446439
//give it a small chance to die gracefully
447440
if (!bgThread.Join(500))
448441
{
442+
#if !NETSTANDARD1_3
449443
//Ideally we shouldn't get here, but lets try our hardest to clean it up
450444
Log.Warn("Interrupting previous Background Thread: " + bgThread.Name);
451445
bgThread.Interrupt();
@@ -454,11 +448,11 @@ private void KillBgThreadIfExists()
454448
Log.Warn(bgThread.Name + " just wont die, so we're now aborting it...");
455449
bgThread.Abort();
456450
}
451+
#endif
457452
}
458453
bgThread = null;
459454
}
460455
}
461-
#endif
462456

463457
private void SleepBackOffMultiplier(int continuousErrorsCount)
464458
{
@@ -567,7 +561,6 @@ public virtual void Dispose()
567561
Log.Error("Error OnDispose(): ", ex);
568562
}
569563

570-
#if !NETSTANDARD1_3
571564
try
572565
{
573566
Thread.Sleep(100); //give it a small chance to die gracefully
@@ -577,7 +570,6 @@ public virtual void Dispose()
577570
{
578571
if (this.OnError != null) this.OnError(ex);
579572
}
580-
#endif
581573

582574
DisposeHeartbeatTimer();
583575
}

src/ServiceStack.Redis/project.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"ServiceStack.Text" : "1.0.*",
1919
"ServiceStack.Common" : "1.0.*"
2020
},
21-
"exclude": ["RedisPipeline.cs"],
2221
"frameworks": {
2322
"netstandard1.3": {
2423
"dependencies" : {
2524
"System.Net.Security" : "4.0.0",
2625
"System.Collections.Specialized": "4.0.1",
2726
"System.Collections.NonGeneric": "4.0.1",
28-
"System.Net.NameResolution" : "4.0.0",
29-
"System.Data.Common" : "4.1.0"
27+
"System.Net.NameResolution": "4.0.0",
28+
"System.Data.Common": "4.1.0",
29+
"System.Threading.Thread": "4.0.0"
3030
}
3131
}
3232

0 commit comments

Comments
 (0)