Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: runtime/bin/process_win.cc

Issue 2760293002: [dart:io] Adds a finalizer to _NativeSocket to avoid socket leaks (Closed)
Patch Set: Address comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process.cc ('k') | runtime/bin/reference_counting.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_win.cc
diff --git a/runtime/bin/process_win.cc b/runtime/bin/process_win.cc
index 7903236a0164e4a98365ebf572d97aab1047298e..edc81fb01793e4d579717b94237b62e5ddf1d3f1 100644
--- a/runtime/bin/process_win.cc
+++ b/runtime/bin/process_win.cc
@@ -946,7 +946,9 @@ static Mutex* signal_mutex = new Mutex();
SignalInfo::~SignalInfo() {
- reinterpret_cast<FileHandle*>(fd_)->Close();
+ FileHandle* file_handle = reinterpret_cast<FileHandle*>(fd_);
+ file_handle->Close();
+ file_handle->Release();
}
@@ -1005,7 +1007,12 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
if (signal_handlers == NULL) {
if (SetConsoleCtrlHandler(SignalHandler, true) == 0) {
int error_code = GetLastError();
- delete write_handle;
+ // Since SetConsoleCtrlHandler failed, the IO completion port will
+ // never receive an event for this handle, and will therefore never
+ // release the reference Retained by EnsureInitialized(). So, we
+ // have to do a second Release() here.
+ write_handle->Release();
+ write_handle->Release();
CloseProcessPipe(fds);
SetLastError(error_code);
return -1;
@@ -1038,6 +1045,8 @@ void Process::ClearSignalHandler(intptr_t signal) {
if (signal_handlers == NULL) {
USE(SetConsoleCtrlHandler(SignalHandler, false));
}
+ FileHandle* file_handle = reinterpret_cast<FileHandle*>(handler->fd());
+ file_handle->Release();
}
delete handler;
}
« no previous file with comments | « runtime/bin/process.cc ('k') | runtime/bin/reference_counting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698