WebKit Bugzilla
Attachment 342080 Details for
Bug 186361
: [Win] Fix WorkQueue crash
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP - first trial
186361.diff (text/plain), 3.84 KB, created by
Basuke Suzuki
on 2018-06-06 13:52:58 PDT
(
hide
)
Description:
WIP - first trial
Filename:
MIME Type:
Creator:
Basuke Suzuki
Created:
2018-06-06 13:52:58 PDT
Size:
3.84 KB
patch
obsolete
>diff --git a/Source/WTF/wtf/WorkQueue.h b/Source/WTF/wtf/WorkQueue.h >index 85eca62c0ca..38db96bf747 100644 >--- a/Source/WTF/wtf/WorkQueue.h >+++ b/Source/WTF/wtf/WorkQueue.h >@@ -100,9 +100,6 @@ private: > bool tryRegisterAsWorkThread(); > void unregisterAsWorkThread(); > void performWorkOnRegisteredWorkThread(); >- >- static void unregisterWaitAndDestroyItemSoon(Ref<WorkItemContext>&&); >- static DWORD WINAPI unregisterWaitAndDestroyItemCallback(void* context); > #endif > > #if USE(COCOA_EVENT_LOOP) >diff --git a/Source/WTF/wtf/win/WorkItemContext.h b/Source/WTF/wtf/win/WorkItemContext.h >index 0aa15c75269..937208c6af7 100644 >--- a/Source/WTF/wtf/win/WorkItemContext.h >+++ b/Source/WTF/wtf/win/WorkItemContext.h >@@ -45,7 +45,7 @@ public: > virtual ~WorkItemContext(); > > Win32Handle& handle() { return m_handle; } >- Win32Handle& waitHandle() { return m_waitHandle; } >+ HANDLE& waitHandle() { return m_waitHandle; } > Function<void()>& function() { return m_function; } > WorkQueue* queue() const { return m_queue.get(); } > >@@ -53,7 +53,7 @@ private: > WorkItemContext(HANDLE, HANDLE, Function<void()>&&, WorkQueue*); > > Win32Handle m_handle; >- Win32Handle m_waitHandle; >+ HANDLE m_waitHandle; > Function<void()> m_function; > RefPtr<WorkQueue> m_queue; > }; >diff --git a/Source/WTF/wtf/win/WorkQueueWin.cpp b/Source/WTF/wtf/win/WorkQueueWin.cpp >index 41bfde096d7..34e84cbbf1e 100644 >--- a/Source/WTF/wtf/win/WorkQueueWin.cpp >+++ b/Source/WTF/wtf/win/WorkQueueWin.cpp >@@ -51,7 +51,7 @@ void WorkQueue::registerHandle(HANDLE handle, Function<void()>&& function) > { > Ref<WorkItemContext> context = WorkItemContext::create(handle, nullptr, WTFMove(function), this); > >- if (!::RegisterWaitForSingleObject(&context->waitHandle().m_handle, handle, handleCallback, context.ptr(), INFINITE, WT_EXECUTEDEFAULT)) >+ if (!::RegisterWaitForSingleObject(&context->waitHandle(), handle, handleCallback, context.ptr(), INFINITE, WT_EXECUTEDEFAULT)) > ASSERT_WITH_MESSAGE(m_timerQueue, "::RegisterWaitForSingleObject %lu", ::GetLastError()); > > auto locker = holdLock(m_itemsMapLock); >@@ -64,7 +64,9 @@ void WorkQueue::unregisterAndCloseHandle(HANDLE handle) > auto locker = holdLock(m_itemsMapLock); > ASSERT_ARG(handle, m_itemsMap.contains(handle)); > >- unregisterWaitAndDestroyItemSoon(m_itemsMap.take(handle).value()); >+ auto workItem = m_itemsMap.take(handle).value(); >+ if (!::UnregisterWaitEx(workItem->waitHandle(), INVALID_HANDLE_VALUE)) >+ ASSERT_WITH_MESSAGE(false, "::UnregisterWaitEx failed with '%s'", ::GetLastError()); > } > > DWORD WorkQueue::workThreadCallback(void* context) >@@ -222,26 +224,4 @@ void WorkQueue::dispatchAfter(Seconds duration, Function<void()>&& function) > context.leakRef(); > } > >-void WorkQueue::unregisterWaitAndDestroyItemSoon(Ref<WorkItemContext>&& workItem) >-{ >- // We're going to make a blocking call to ::UnregisterWaitEx before closing the handle. (The >- // blocking version of ::UnregisterWaitEx is much simpler than the non-blocking version.) If we >- // do this on the current thread, we'll deadlock if we're currently in a callback function for >- // the wait we're unregistering. So instead we do it asynchronously on some other worker thread. >- ::QueueUserWorkItem(unregisterWaitAndDestroyItemCallback, workItem.ptr(), WT_EXECUTEDEFAULT); >-} >- >-DWORD WINAPI WorkQueue::unregisterWaitAndDestroyItemCallback(void* data) >-{ >- ASSERT_ARG(data, data); >- WorkItemContext* context = static_cast<WorkItemContext*>(data); >- >- // Now that we know we're not in a callback function for the wait we're unregistering, we can >- // make a blocking call to ::UnregisterWaitEx. >- if (!::UnregisterWaitEx(context->waitHandle().get(), INVALID_HANDLE_VALUE)) >- ASSERT_WITH_MESSAGE(false, "::UnregisterWaitEx failed with '%s'", ::GetLastError()); >- >- return 0; >-} >- > } // namespace WTF
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186361
: 342080