This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-14
lines changed
Expand file tree Collapse file tree 1 file changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,24 @@ public IRedisPubSubServer Start()
9797 //Only 1 thread allowed past
9898 if ( Interlocked . CompareExchange ( ref status , Status . Starting , Status . Stopped ) == Status . Stopped ) //Should only be 1 thread past this point
9999 {
100- try
100+ var initErrors = 0 ;
101+ bool hasInit = false ;
102+ while ( ! hasInit )
101103 {
102- Init ( ) ;
104+ try
105+ {
106+ Init ( ) ;
107+ hasInit = true ;
108+ }
109+ catch ( Exception ex )
110+ {
111+ OnError ? . Invoke ( ex ) ;
112+ SleepBackOffMultiplier ( initErrors ++ ) ;
113+ }
114+ }
103115
116+ try
117+ {
104118 SleepBackOffMultiplier ( Interlocked . CompareExchange ( ref noOfContinuousErrors , 0 , 0 ) ) ;
105119
106120 OnStart ? . Invoke ( ) ;
@@ -137,19 +151,12 @@ public IRedisPubSubServer Start()
137151
138152 private void Init ( )
139153 {
140- try
154+ using ( var redis = ClientsManager . GetReadOnlyClient ( ) )
141155 {
142- using ( var redis = ClientsManager . GetReadOnlyClient ( ) )
143- {
144- startedAt = Stopwatch . StartNew ( ) ;
145- serverTimeAtStart = IsSentinelSubscription
146- ? DateTime . UtcNow
147- : redis . GetServerTime ( ) ;
148- }
149- }
150- catch ( Exception ex )
151- {
152- OnError ? . Invoke ( ex ) ;
156+ startedAt = Stopwatch . StartNew ( ) ;
157+ serverTimeAtStart = IsSentinelSubscription
158+ ? DateTime . UtcNow
159+ : redis . GetServerTime ( ) ;
153160 }
154161
155162 DisposeHeartbeatTimer ( ) ;
You can’t perform that action at this time.
0 commit comments