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

Unified Diff: runtime/vm/thread_interrupter_win.cc

Issue 294193003: Fix thread-interrupter shutdown on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup based on typedef fix. Created 6 years, 7 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/vm/thread_interrupter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_interrupter_win.cc
diff --git a/runtime/vm/thread_interrupter_win.cc b/runtime/vm/thread_interrupter_win.cc
index 4058da30d25d94c791265c7061b60af4cd69e553..4f952e1735bae106958493d79df0824bf2bdbb58 100644
--- a/runtime/vm/thread_interrupter_win.cc
+++ b/runtime/vm/thread_interrupter_win.cc
@@ -16,11 +16,11 @@ DECLARE_FLAG(bool, trace_thread_interrupter);
class ThreadInterrupterWin : public AllStatic {
public:
- static bool GrabRegisters(ThreadId thread, InterruptedThreadState* state) {
+ static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) {
CONTEXT context;
memset(&context, 0, sizeof(context));
context.ContextFlags = CONTEXT_FULL;
- if (GetThreadContext(thread, &context) != 0) {
+ if (GetThreadContext(handle, &context) != 0) {
#if defined(TARGET_ARCH_IA32)
state->pc = static_cast<uintptr_t>(context.Eip);
state->fp = static_cast<uintptr_t>(context.Ebp);
@@ -39,33 +39,42 @@ class ThreadInterrupterWin : public AllStatic {
static void Interrupt(InterruptableThreadState* state) {
- ASSERT(GetCurrentThread() != state->id);
- DWORD result = SuspendThread(state->id);
+ ASSERT(!Thread::Compare(GetCurrentThreadId(), state->id));
+ HANDLE handle = OpenThread(THREAD_GET_CONTEXT |
+ THREAD_SUSPEND_RESUME,
+ false,
+ state->id);
+ ASSERT(handle != NULL);
+ DWORD result = SuspendThread(handle);
if (result == kThreadError) {
if (FLAG_trace_thread_interrupter) {
OS::Print("ThreadInterrupted failed to suspend thread %p\n",
reinterpret_cast<void*>(state->id));
}
+ CloseHandle(handle);
return;
}
InterruptedThreadState its;
its.tid = state->id;
- if (!GrabRegisters(state->id, &its)) {
+ if (!GrabRegisters(handle, &its)) {
// Failed to get thread registers.
- ResumeThread(state->id);
+ ResumeThread(handle);
if (FLAG_trace_thread_interrupter) {
OS::Print("ThreadInterrupted failed to get registers for %p\n",
reinterpret_cast<void*>(state->id));
}
+ CloseHandle(handle);
return;
}
if (state->callback == NULL) {
// No callback registered.
- ResumeThread(state->id);
+ ResumeThread(handle);
+ CloseHandle(handle);
return;
}
state->callback(its, state->data);
- ResumeThread(state->id);
+ ResumeThread(handle);
+ CloseHandle(handle);
}
};
« no previous file with comments | « runtime/vm/thread_interrupter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698