@@ -130,12 +130,19 @@ public IPooledSocketResult Acquire()
130
130
if ( ! this . isInitialized )
131
131
{
132
132
poolInitSemaphore . Wait ( ) ;
133
- if ( ! this . isInitialized )
133
+ try
134
134
{
135
- var startTime = DateTime . Now ;
136
- this . internalPoolImpl . InitPool ( ) ;
137
- this . isInitialized = true ;
138
- _logger . LogInformation ( "MemcachedInitPool-cost: {0}ms" , ( DateTime . Now - startTime ) . TotalMilliseconds ) ;
135
+ if ( ! this . isInitialized )
136
+ {
137
+ var startTime = DateTime . Now ;
138
+ this . internalPoolImpl . InitPool ( ) ;
139
+ this . isInitialized = true ;
140
+ _logger . LogInformation ( "MemcachedInitPool-cost: {0}ms" , ( DateTime . Now - startTime ) . TotalMilliseconds ) ;
141
+ }
142
+ }
143
+ finally
144
+ {
145
+ poolInitSemaphore . Release ( ) ;
139
146
}
140
147
}
141
148
@@ -151,10 +158,6 @@ public IPooledSocketResult Acquire()
151
158
result . Fail ( message , e ) ;
152
159
return result ;
153
160
}
154
- finally
155
- {
156
- poolInitSemaphore . Release ( ) ;
157
- }
158
161
}
159
162
160
163
/// <summary>
@@ -166,12 +169,18 @@ public async Task<IPooledSocketResult> AcquireAsync()
166
169
if ( ! this . isInitialized )
167
170
{
168
171
await poolInitSemaphore . WaitAsync ( ) ;
169
- if ( ! this . isInitialized )
172
+ try
173
+ {
174
+ if ( ! this . isInitialized )
175
+ {
176
+ var startTime = DateTime . Now ;
177
+ await this . internalPoolImpl . InitPoolAsync ( ) ;
178
+ this . isInitialized = true ;
179
+ _logger . LogInformation ( "MemcachedInitPool-cost: {0}ms" , ( DateTime . Now - startTime ) . TotalMilliseconds ) ;
180
+ }
181
+ }
182
+ finally
170
183
{
171
- var startTime = DateTime . Now ;
172
- await this . internalPoolImpl . InitPoolAsync ( ) ;
173
- this . isInitialized = true ;
174
- _logger . LogInformation ( "MemcachedInitPool-cost: {0}ms" , ( DateTime . Now - startTime ) . TotalMilliseconds ) ;
175
184
poolInitSemaphore . Release ( ) ;
176
185
}
177
186
}
0 commit comments