This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree 4 files changed +30
-13
lines changed
src/Microsoft.AspNet.Server.Kestrel 4 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ _ReSharper.*/
7
7
packages /
8
8
artifacts /
9
9
PublishProfiles /
10
+ .vs /
10
11
* .user
11
12
* .suo
12
13
* .cache
Original file line number Diff line number Diff line change @@ -53,12 +53,16 @@ public void Stop(TimeSpan timeout)
53
53
Post ( OnStop , null ) ;
54
54
if ( ! _thread . Join ( ( int ) timeout . TotalMilliseconds ) )
55
55
{
56
- Post ( OnStopImmediate , null ) ;
56
+ Post ( OnStopRude , null ) ;
57
57
if ( ! _thread . Join ( ( int ) timeout . TotalMilliseconds ) )
58
58
{
59
+ Post ( OnStopImmediate , null ) ;
60
+ if ( ! _thread . Join ( ( int ) timeout . TotalMilliseconds ) )
61
+ {
59
62
#if DNX451
60
- _thread . Abort ( ) ;
63
+ _thread . Abort ( ) ;
61
64
#endif
65
+ }
62
66
}
63
67
}
64
68
if ( _closeError != null )
@@ -72,6 +76,21 @@ private void OnStop(object obj)
72
76
_post . Unreference ( ) ;
73
77
}
74
78
79
+ private void OnStopRude ( object obj )
80
+ {
81
+ _engine . Libuv . walk (
82
+ _loop ,
83
+ ( ptr , arg ) =>
84
+ {
85
+ var handle = UvMemory . FromIntPtr < UvHandle > ( ptr ) ;
86
+ if ( handle != _post )
87
+ {
88
+ handle . Dispose ( ) ;
89
+ }
90
+ } ,
91
+ IntPtr . Zero ) ;
92
+ }
93
+
75
94
private void OnStopImmediate ( object obj )
76
95
{
77
96
_stopImmediate = true ;
@@ -133,14 +152,8 @@ private void ThreadStart(object parameter)
133
152
// run the loop one more time to delete the open handles
134
153
_post . Reference ( ) ;
135
154
_post . DangerousClose ( ) ;
136
- _engine . Libuv . walk (
137
- _loop ,
138
- ( ptr , arg ) =>
139
- {
140
- var handle = UvMemory . FromIntPtr < UvHandle > ( ptr ) ;
141
- handle . Dispose ( ) ;
142
- } ,
143
- IntPtr . Zero ) ;
155
+
156
+ // Ensure the "DangerousClose" operation completes in the event loop.
144
157
var ran2 = _loop . Run ( ) ;
145
158
146
159
_loop . Dispose ( ) ;
@@ -203,7 +216,7 @@ private void DoPostCloseHandle()
203
216
queue = _closeHandleAdding ;
204
217
_closeHandleAdding = _closeHandleRunning ;
205
218
_closeHandleRunning = queue ;
206
- }
219
+ }
207
220
while ( queue . Count != 0 )
208
221
{
209
222
var closeHandle = queue . Dequeue ( ) ;
File renamed without changes.
Original file line number Diff line number Diff line change @@ -32,9 +32,12 @@ protected override bool ReleaseHandle()
32
32
{
33
33
_uv . close ( memory , _destroyMemory ) ;
34
34
}
35
- else
35
+ else if ( _queueCloseHandle != null )
36
36
{
37
- _queueCloseHandle ( memory2 => _uv . close ( memory2 , _destroyMemory ) , memory ) ;
37
+ // This can be called from the finalizer.
38
+ // Ensure the closure doesn't reference "this".
39
+ var uv = _uv ;
40
+ _queueCloseHandle ( memory2 => uv . close ( memory2 , _destroyMemory ) , memory ) ;
38
41
}
39
42
}
40
43
return true ;
You can’t perform that action at this time.
0 commit comments