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()
97
97
//Only 1 thread allowed past
98
98
if ( Interlocked . CompareExchange ( ref status , Status . Starting , Status . Stopped ) == Status . Stopped ) //Should only be 1 thread past this point
99
99
{
100
- try
100
+ var initErrors = 0 ;
101
+ bool hasInit = false ;
102
+ while ( ! hasInit )
101
103
{
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
+ }
103
115
116
+ try
117
+ {
104
118
SleepBackOffMultiplier ( Interlocked . CompareExchange ( ref noOfContinuousErrors , 0 , 0 ) ) ;
105
119
106
120
OnStart ? . Invoke ( ) ;
@@ -137,19 +151,12 @@ public IRedisPubSubServer Start()
137
151
138
152
private void Init ( )
139
153
{
140
- try
154
+ using ( var redis = ClientsManager . GetReadOnlyClient ( ) )
141
155
{
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 ( ) ;
153
160
}
154
161
155
162
DisposeHeartbeatTimer ( ) ;
You can’t perform that action at this time.
0 commit comments