|
[dart:io] Adds a finalizer to _NativeSocket to avoid socket leaks
The finalizer sends the "close" message to the EventHandler for the
file descriptor in the _NativeSocket's native field. To avoid races and
spurious messages, this CL stores a pointer to a wrapper object in the
native field instead of the file descriptor. All messsages about the
_NativeSocket sent to the EventHandler use the wrapper object instead of
the file descriptor. When the EventHandler closes the file, the file
descriptor in the wrapper object is set to -1 so that the finalizer will
instead do nothing.
On Windows, there is another level of indirection since the OS HANDLEs
were already wrapped in various kinds of Handle objects. As an additional
complication, ClientSocket close on Windows is asynchronous, so the
EventHandler may shutdown before all of the ClientSocket Handles can be
destroyed.
related #27898, #28081
R=johnmccutchan@google.com
Committed: https://github.com/dart-lang/sdk/commit/89dba57bcf6b5c6a28f9adee4b3f86195f64f6ae
Total comments: 7
Total comments: 4
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+563 lines, -174 lines) |
Patch |
|
M |
runtime/bin/error_exit.cc
|
View
|
1
2
3
4
5
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
runtime/bin/eventhandler.h
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
|
M |
runtime/bin/eventhandler.cc
|
View
|
|
2 chunks |
+16 lines, -7 lines |
0 comments
|
Download
|
|
M |
runtime/bin/eventhandler_android.cc
|
View
|
1
2
3
4
5
6
7
8
9
|
3 chunks |
+10 lines, -3 lines |
0 comments
|
Download
|
|
M |
runtime/bin/eventhandler_fuchsia.cc
|
View
|
1
2
3
4
5
6
7
8
9
|
4 chunks |
+10 lines, -2 lines |
0 comments
|
Download
|
|
M |
runtime/bin/eventhandler_linux.cc
|
View
|
1
2
3
4
5
6
|
3 chunks |
+10 lines, -4 lines |
0 comments
|
Download
|
|
M |
runtime/bin/eventhandler_macos.cc
|
View
|
1
2
3
4
5
6
7
8
9
|
3 chunks |
+10 lines, -3 lines |
0 comments
|
Download
|
|
M |
runtime/bin/eventhandler_win.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
10 chunks |
+31 lines, -11 lines |
0 comments
|
Download
|
|
M |
runtime/bin/eventhandler_win.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
15 chunks |
+135 lines, -40 lines |
0 comments
|
Download
|
|
M |
runtime/bin/main.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
2 chunks |
+2 lines, -0 lines |
0 comments
|
Download
|
|
M |
runtime/bin/process.h
|
View
|
1
2
3
4
5
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
|
M |
runtime/bin/process.cc
|
View
|
1
2
3
4
5
|
3 chunks |
+25 lines, -10 lines |
0 comments
|
Download
|
|
M |
runtime/bin/process_win.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
3 chunks |
+11 lines, -2 lines |
0 comments
|
Download
|
|
M |
runtime/bin/reference_counting.h
|
View
|
1
2
3
4
5
6
|
1 chunk |
+28 lines, -6 lines |
0 comments
|
Download
|
|
M |
runtime/bin/socket.h
|
View
|
1
2
3
4
|
9 chunks |
+38 lines, -12 lines |
0 comments
|
Download
|
|
M |
runtime/bin/socket.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
39 chunks |
+132 lines, -68 lines |
0 comments
|
Download
|
|
M |
runtime/bin/socket_android.cc
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+9 lines, -0 lines |
0 comments
|
Download
|
|
M |
runtime/bin/socket_fuchsia.cc
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+9 lines, -0 lines |
0 comments
|
Download
|
|
M |
runtime/bin/socket_linux.cc
|
View
|
1
2
3
4
5
6
|
1 chunk |
+9 lines, -0 lines |
0 comments
|
Download
|
|
M |
runtime/bin/socket_macos.cc
|
View
|
1
2
3
4
5
6
7
|
1 chunk |
+9 lines, -0 lines |
0 comments
|
Download
|
|
M |
runtime/bin/socket_win.cc
|
View
|
1
2
3
4
5
|
6 chunks |
+22 lines, -5 lines |
0 comments
|
Download
|
|
M |
tests/standalone/io/socket_bind_test.dart
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
|
A |
tests/standalone/io/socket_finalizer_test.dart
|
View
|
1
2
3
|
1 chunk |
+39 lines, -0 lines |
0 comments
|
Download
|
Total messages: 13 (6 generated)
|