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

Unified Diff: runtime/bin/process_win.cc

Issue 2961993002: [dart:io] Fixes a crash in VM shutdown when signals are watched (Closed)
Patch Set: Fixes for Windows, comment Created 3 years, 6 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_macos.cc ('k') | tests/standalone/io/signals_exception_test.dart » ('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 21c7ae44e9b3cbc840a070c74475f9a31e67d1ba..bcf0c79dc80d8557b1ae59d48b8b4247967110aa 100644
--- a/runtime/bin/process_win.cc
+++ b/runtime/bin/process_win.cc
@@ -1043,7 +1043,7 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
}
-void Process::ClearSignalHandler(intptr_t signal) {
+void Process::ClearSignalHandler(intptr_t signal, Dart_Port port) {
signal = GetWinSignal(signal);
if (signal == -1) {
return;
@@ -1051,24 +1051,27 @@ void Process::ClearSignalHandler(intptr_t signal) {
MutexLocker lock(signal_mutex);
SignalInfo* handler = signal_handlers;
while (handler != NULL) {
- if ((handler->port() == Dart_GetMainPortId()) &&
- (handler->signal() == signal)) {
- handler->Unlink();
- break;
- }
- handler = handler->next();
- }
- if (handler != NULL) {
- if (signal_handlers == handler) {
- signal_handlers = handler->next();
+ bool remove = false;
+ if (handler->signal() == signal) {
+ if ((port == ILLEGAL_PORT) || (handler->port() == port)) {
+ if (signal_handlers == handler) {
+ signal_handlers = handler->next();
+ }
+ handler->Unlink();
+ FileHandle* file_handle = reinterpret_cast<FileHandle*>(handler->fd());
+ file_handle->Release();
+ remove = true;
+ }
}
- if (signal_handlers == NULL) {
- USE(SetConsoleCtrlHandler(SignalHandler, false));
+ SignalInfo* next = handler->next();
+ if (remove) {
+ delete handler;
}
- FileHandle* file_handle = reinterpret_cast<FileHandle*>(handler->fd());
- file_handle->Release();
+ handler = next;
+ }
+ if (signal_handlers == NULL) {
+ USE(SetConsoleCtrlHandler(SignalHandler, false));
}
- delete handler;
}
} // namespace bin
« no previous file with comments | « runtime/bin/process_macos.cc ('k') | tests/standalone/io/signals_exception_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698