Title: [277266] trunk/Source/WebKit
- Revision
- 277266
- Author
- [email protected]
- Date
- 2021-05-10 09:35:17 -0700 (Mon, 10 May 2021)
Log Message
Have IPC::Semaphore::wait return a state boolean
https://bugs.webkit.org/show_bug.cgi?id=225587
Reviewed by Alex Christensen.
Semaphore::wait might return early, in particular if its sempahore is destroyed.
To handle this case, return false in that case to allow specific handling by caller.
Use return state in RemoteCaptureSampleManager::RemoteAudio::startThread as a way to stop the capture thread.
Covered by existing tests.
* Platform/IPC/IPCSemaphore.h:
* Platform/IPC/darwin/IPCSemaphoreDarwin.cpp:
(IPC::Semaphore::wait):
* Platform/IPC/unix/IPCSemaphoreUnix.cpp:
(IPC::Semaphore::wait):
* Platform/IPC/win/IPCSemaphoreWin.cpp:
(IPC::Semaphore::wait):
* WebProcess/cocoa/RemoteCaptureSampleManager.cpp:
(WebKit::RemoteCaptureSampleManager::RemoteAudio::startThread):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (277265 => 277266)
--- trunk/Source/WebKit/ChangeLog 2021-05-10 16:26:17 UTC (rev 277265)
+++ trunk/Source/WebKit/ChangeLog 2021-05-10 16:35:17 UTC (rev 277266)
@@ -1,3 +1,25 @@
+2021-05-10 Youenn Fablet <[email protected]>
+
+ Have IPC::Semaphore::wait return a state boolean
+ https://bugs.webkit.org/show_bug.cgi?id=225587
+
+ Reviewed by Alex Christensen.
+
+ Semaphore::wait might return early, in particular if its sempahore is destroyed.
+ To handle this case, return false in that case to allow specific handling by caller.
+ Use return state in RemoteCaptureSampleManager::RemoteAudio::startThread as a way to stop the capture thread.
+ Covered by existing tests.
+
+ * Platform/IPC/IPCSemaphore.h:
+ * Platform/IPC/darwin/IPCSemaphoreDarwin.cpp:
+ (IPC::Semaphore::wait):
+ * Platform/IPC/unix/IPCSemaphoreUnix.cpp:
+ (IPC::Semaphore::wait):
+ * Platform/IPC/win/IPCSemaphoreWin.cpp:
+ (IPC::Semaphore::wait):
+ * WebProcess/cocoa/RemoteCaptureSampleManager.cpp:
+ (WebKit::RemoteCaptureSampleManager::RemoteAudio::startThread):
+
2021-05-10 Aditya Keerthi <[email protected]>
[iPadOS] Do not present custom input peripherals when switching back to a tab with a focused element
Modified: trunk/Source/WebKit/Platform/IPC/IPCSemaphore.h (277265 => 277266)
--- trunk/Source/WebKit/Platform/IPC/IPCSemaphore.h 2021-05-10 16:26:17 UTC (rev 277265)
+++ trunk/Source/WebKit/Platform/IPC/IPCSemaphore.h 2021-05-10 16:35:17 UTC (rev 277266)
@@ -55,7 +55,7 @@
static Optional<Semaphore> decode(Decoder&);
void signal();
- void wait();
+ bool wait();
bool waitFor(Timeout);
#if OS(DARWIN)
Modified: trunk/Source/WebKit/Platform/IPC/darwin/IPCSemaphoreDarwin.cpp (277265 => 277266)
--- trunk/Source/WebKit/Platform/IPC/darwin/IPCSemaphoreDarwin.cpp 2021-05-10 16:26:17 UTC (rev 277265)
+++ trunk/Source/WebKit/Platform/IPC/darwin/IPCSemaphoreDarwin.cpp 2021-05-10 16:35:17 UTC (rev 277266)
@@ -72,10 +72,11 @@
ASSERT_UNUSED(ret, ret == KERN_SUCCESS || ret == KERN_TERMINATED);
}
-void Semaphore::wait()
+bool Semaphore::wait()
{
auto ret = semaphore_wait(m_semaphore);
- ASSERT_UNUSED(ret, ret == KERN_SUCCESS || ret == KERN_TERMINATED);
+ ASSERT(ret == KERN_SUCCESS || ret == KERN_TERMINATED);
+ return ret == KERN_SUCCESS;
}
bool Semaphore::waitFor(Timeout timeout)
Modified: trunk/Source/WebKit/Platform/IPC/unix/IPCSemaphoreUnix.cpp (277265 => 277266)
--- trunk/Source/WebKit/Platform/IPC/unix/IPCSemaphoreUnix.cpp 2021-05-10 16:26:17 UTC (rev 277265)
+++ trunk/Source/WebKit/Platform/IPC/unix/IPCSemaphoreUnix.cpp 2021-05-10 16:35:17 UTC (rev 277266)
@@ -46,8 +46,9 @@
{
}
-void Semaphore::wait()
+bool Semaphore::wait()
{
+ return false;
}
bool Semaphore::waitFor(Timeout)
Modified: trunk/Source/WebKit/Platform/IPC/win/IPCSemaphoreWin.cpp (277265 => 277266)
--- trunk/Source/WebKit/Platform/IPC/win/IPCSemaphoreWin.cpp 2021-05-10 16:26:17 UTC (rev 277265)
+++ trunk/Source/WebKit/Platform/IPC/win/IPCSemaphoreWin.cpp 2021-05-10 16:35:17 UTC (rev 277266)
@@ -68,9 +68,9 @@
ReleaseSemaphore(m_semaphoreHandle, 1, nullptr);
}
-void Semaphore::wait()
+bool Semaphore::wait()
{
- WaitForSingleObject(m_semaphoreHandle, INFINITE);
+ return WAIT_OBJECT_0 == WaitForSingleObject(m_semaphoreHandle, INFINITE);
}
bool Semaphore::waitFor(Timeout timeout)
Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp (277265 => 277266)
--- trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp 2021-05-10 16:26:17 UTC (rev 277265)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp 2021-05-10 16:35:17 UTC (rev 277266)
@@ -177,8 +177,8 @@
auto threadLoop = [this]() mutable {
m_readOffset = 0;
do {
- // If waitFor fails, the semaphore on the other side was probably destroyed and we should just exit here and wait to launch a new thread.
- if (!m_semaphore.waitFor(Seconds::infinity()))
+ // If wait fails, the semaphore on the other side was probably destroyed and we should just exit here and wait to launch a new thread.
+ if (!m_semaphore.wait())
break;
if (m_shouldStopThread)
break;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes