@@ -116,21 +116,17 @@ public void FailoverTo(IEnumerable<string> readWriteHosts, IEnumerable<string> r
116
116
/// <returns></returns>
117
117
public IRedisClient GetClient ( )
118
118
{
119
- int section = 1 ;
120
119
try
121
120
{
122
121
var inactivePoolIndex = - 1 ;
123
122
lock ( clients )
124
123
{
125
- section = 2 ;
126
124
AssertValidPool ( ) ;
127
125
128
- section = 3 ;
129
126
RedisClient inActiveClient ;
130
127
//-1 when no available clients otherwise index of reservedSlot or existing Client
131
128
inactivePoolIndex = GetInActiveClient ( out inActiveClient ) ;
132
129
133
- section = 4 ;
134
130
//inActiveClient != null only for Valid InActive Clients
135
131
if ( inActiveClient != null )
136
132
{
@@ -144,36 +140,28 @@ public IRedisClient GetClient()
144
140
//Reaches here when there's no Valid InActive Clients
145
141
try
146
142
{
147
- section = 5 ;
148
143
//inactivePoolIndex == -1 || index of reservedSlot || index of invalid client
149
144
var existingClient = inactivePoolIndex >= 0 && inactivePoolIndex < clients . Length
150
145
? clients [ inactivePoolIndex ]
151
146
: null ;
152
147
153
- section = 5 ;
154
148
if ( existingClient != null && existingClient != reservedSlot && existingClient . HadExceptions )
155
149
{
156
- section = 6 ;
157
150
RedisState . DeactivateClient ( existingClient ) ;
158
151
}
159
152
160
- section = 7 ;
161
- var newClient = RedisResolver . CreateMasterClient ( Math . Max ( inactivePoolIndex , 0 ) ) ;
162
- section = 8 ;
163
- newClient = InitNewClient ( newClient ) ;
153
+ var newClient = InitNewClient ( RedisResolver . CreateMasterClient ( Math . Max ( inactivePoolIndex , 0 ) ) ) ;
164
154
165
155
//Put all blocking I/O or potential Exceptions before lock
166
156
lock ( clients )
167
157
{
168
158
//Create new client outside of pool when max pool size exceeded
169
159
//Reverting free-slot not needed when -1 since slwo wasn't reserved or
170
160
//when existingClient changed (failover) since no longer reserver
171
- section = 9 ;
172
161
var stillReserved = inactivePoolIndex >= 0 && inactivePoolIndex < clients . Length &&
173
- clients [ inactivePoolIndex ] == existingClient ;
162
+ clients [ inactivePoolIndex ] == existingClient ;
174
163
if ( inactivePoolIndex == - 1 || ! stillReserved )
175
164
{
176
- section = 10 ;
177
165
if ( Log . IsDebugEnabled )
178
166
Log . Debug ( "clients[inactivePoolIndex] != existingClient: {0}" . Fmt ( ! stillReserved ? "!stillReserved" : "-1" ) ) ;
179
167
@@ -184,7 +172,6 @@ public IRedisClient GetClient()
184
172
return newClient ;
185
173
}
186
174
187
- section = 11 ;
188
175
poolIndex ++ ;
189
176
clients [ inactivePoolIndex ] = newClient ;
190
177
return newClient ;
@@ -195,7 +182,6 @@ public IRedisClient GetClient()
195
182
//Revert free-slot for any I/O exceptions that can throw (before lock)
196
183
lock ( clients )
197
184
{
198
- section = 12 ;
199
185
if ( inactivePoolIndex >= 0 && inactivePoolIndex < clients . Length )
200
186
{
201
187
clients [ inactivePoolIndex ] = null ;
@@ -204,20 +190,9 @@ public IRedisClient GetClient()
204
190
throw ;
205
191
}
206
192
}
207
- catch ( IndexOutOfRangeException ex )
208
- {
209
- throw new Exception ( "Error after section: " + section , ex ) ;
210
- }
211
193
finally
212
194
{
213
- try
214
- {
215
- RedisState . DisposeExpiredClients ( ) ;
216
- }
217
- catch ( IndexOutOfRangeException ex )
218
- {
219
- throw new Exception ( "Error at RedisState.DisposeExpiredClients()" , ex ) ;
220
- }
195
+ RedisState . DisposeExpiredClients ( ) ;
221
196
}
222
197
}
223
198
0 commit comments