Title: [289519] trunk
Revision
289519
Author
ross.kirsl...@sony.com
Date
2022-02-09 22:00:01 -0800 (Wed, 09 Feb 2022)

Log Message

SharedMemoryUnix should use SHM_ANON when available
https://bugs.webkit.org/show_bug.cgi?id=236416

Reviewed by Don Olmstead.

.:

* Source/cmake/OptionsCommon.cmake: Check for SHM_ANON.

Source/WebKit:

FreeBSD is able to use shm_open(SHM_ANON, ...) to create an anonymous shared memory object which is subject to RAII:
https://www.freebsd.org/cgi/man.cgi?query=shm_open

* Platform/unix/SharedMemoryUnix.cpp:
(WebKit::createSharedMemory):
Make use of SHM_ANON if we have it.

Modified Paths

Diff

Modified: trunk/ChangeLog (289518 => 289519)


--- trunk/ChangeLog	2022-02-10 05:18:02 UTC (rev 289518)
+++ trunk/ChangeLog	2022-02-10 06:00:01 UTC (rev 289519)
@@ -1,3 +1,12 @@
+2022-02-09  Ross Kirsling  <ross.kirsl...@sony.com>
+
+        SharedMemoryUnix should use SHM_ANON when available
+        https://bugs.webkit.org/show_bug.cgi?id=236416
+
+        Reviewed by Don Olmstead.
+
+        * Source/cmake/OptionsCommon.cmake: Check for SHM_ANON.
+
 2022-02-09  Adrian Perez de Castro  <ape...@igalia.com>
 
         [CMake] REGRESSION(r288994): Setting multiple values in LDFLAGS causes incorrect linker detection

Modified: trunk/Source/WebKit/ChangeLog (289518 => 289519)


--- trunk/Source/WebKit/ChangeLog	2022-02-10 05:18:02 UTC (rev 289518)
+++ trunk/Source/WebKit/ChangeLog	2022-02-10 06:00:01 UTC (rev 289519)
@@ -1,3 +1,17 @@
+2022-02-09  Ross Kirsling  <ross.kirsl...@sony.com>
+
+        SharedMemoryUnix should use SHM_ANON when available
+        https://bugs.webkit.org/show_bug.cgi?id=236416
+
+        Reviewed by Don Olmstead.
+
+        FreeBSD is able to use shm_open(SHM_ANON, ...) to create an anonymous shared memory object which is subject to RAII:
+        https://www.freebsd.org/cgi/man.cgi?query=shm_open
+
+        * Platform/unix/SharedMemoryUnix.cpp:
+        (WebKit::createSharedMemory):
+        Make use of SHM_ANON if we have it.
+
 2022-02-09  Said Abou-Hallawa  <s...@apple.com>
 
         [GPU Process] Move ImageBuffer::createCompatibleImageBuffer() and SVGRenderingContext::createImageBuffer to GraphicsContext

Modified: trunk/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp (289518 => 289519)


--- trunk/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp	2022-02-10 05:18:02 UTC (rev 289518)
+++ trunk/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp	2022-02-10 06:00:01 UTC (rev 289519)
@@ -146,6 +146,11 @@
     }
 #endif
 
+#if HAVE(SHM_ANON)
+    do {
+        fileDescriptor = shm_open(SHM_ANON, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
+    } while (fileDescriptor == -1 && errno == EINTR);
+#else
     CString tempName;
     for (int tries = 0; fileDescriptor == -1 && tries < 10; ++tries) {
         String name = String("/WK2SharedMemory.") + String::number(static_cast<unsigned>(WTF::randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)));
@@ -158,6 +163,7 @@
 
     if (fileDescriptor != -1)
         shm_unlink(tempName.data());
+#endif
 
     return fileDescriptor;
 }

Modified: trunk/Source/cmake/OptionsCommon.cmake (289518 => 289519)


--- trunk/Source/cmake/OptionsCommon.cmake	2022-02-10 05:18:02 UTC (rev 289518)
+++ trunk/Source/cmake/OptionsCommon.cmake	2022-02-10 06:00:01 UTC (rev 289519)
@@ -203,6 +203,7 @@
 if (NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin"))
     WEBKIT_CHECK_HAVE_SYMBOL(HAVE_PTHREAD_MAIN_NP pthread_main_np pthread_np.h)
 endif ()
+WEBKIT_CHECK_HAVE_SYMBOL(HAVE_SHM_ANON SHM_ANON sys/mman.h)
 WEBKIT_CHECK_HAVE_SYMBOL(HAVE_TIMINGSAFE_BCMP timingsafe_bcmp string.h)
 # Windows has signal.h but is missing symbols that are used in calls to signal.
 WEBKIT_CHECK_HAVE_SYMBOL(HAVE_SIGNAL_H SIGTRAP signal.h)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to