This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed
src/Microsoft.AspNetCore.Server.Kestrel/Internal/Networking Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ private unsafe void Write(
125
125
{
126
126
_callback = null ;
127
127
_state = null ;
128
- Unpin ( this ) ;
128
+ UnpinGcHandles ( ) ;
129
129
throw ;
130
130
}
131
131
}
@@ -200,31 +200,36 @@ private unsafe void WriteArraySegmentInternal(
200
200
{
201
201
_callback = null ;
202
202
_state = null ;
203
- Unpin ( this ) ;
203
+ UnpinGcHandles ( ) ;
204
204
throw ;
205
205
}
206
206
}
207
207
208
- private static void Unpin ( UvWriteReq req )
208
+ // Safe handle has instance method called Unpin
209
+ // so using UnpinGcHandles to avoid conflict
210
+ private void UnpinGcHandles ( )
209
211
{
210
- foreach ( var pin in req . _pins )
212
+ var pinList = _pins ;
213
+ var count = pinList . Count ;
214
+ for ( var i = 0 ; i < count ; i ++ )
211
215
{
212
- pin . Free ( ) ;
216
+ pinList [ i ] . Free ( ) ;
213
217
}
218
+ pinList . Clear ( ) ;
214
219
215
- foreach ( var handle in req . _handles )
220
+ var handleList = _handles ;
221
+ count = handleList . Count ;
222
+ for ( var i = 0 ; i < count ; i ++ )
216
223
{
217
- handle . Free ( ) ;
224
+ handleList [ i ] . Free ( ) ;
218
225
}
219
-
220
- req . _pins . Clear ( ) ;
221
- req . _handles . Clear ( ) ;
226
+ handleList . Clear ( ) ;
222
227
}
223
228
224
229
private static void UvWriteCb ( IntPtr ptr , int status )
225
230
{
226
231
var req = FromIntPtr < UvWriteReq > ( ptr ) ;
227
- Unpin ( req ) ;
232
+ req . UnpinGcHandles ( ) ;
228
233
229
234
var callback = req . _callback ;
230
235
req . _callback = null ;
You can’t perform that action at this time.
0 commit comments