Title: [280769] trunk/Source/WebKit
- Revision
- 280769
- Author
- ifernan...@igalia.com
- Date
- 2021-08-09 02:58:22 -0700 (Mon, 09 Aug 2021)
Log Message
Allow custom IPC::Attachment messaging in ConnectionUnix.cpp
https://bugs.webkit.org/show_bug.cgi?id=227740
Reviewed by Žan Doberšek.
In order to share AHardwareBuffer handles via IPC we need to use the AHardwareBuffer_sendHandleToUnixSocket()
and AHardwareBuffer_recvHandleFromUnixSocket() functions. This is not currently compatible with the Attachment
API used in UnixConnection, as those functions use custom messaging into the socked fd.
This patch adds a CustomWriterType Attachment that allows custom messaging going into the socket fd.
* Platform/IPC/unix/ConnectionUnix.cpp:
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (280768 => 280769)
--- trunk/Source/WebKit/ChangeLog 2021-08-09 02:09:10 UTC (rev 280768)
+++ trunk/Source/WebKit/ChangeLog 2021-08-09 09:58:22 UTC (rev 280769)
@@ -1,3 +1,18 @@
+2021-08-09 Imanol Fernandez <ifernan...@igalia.com>
+
+ Allow custom IPC::Attachment messaging in ConnectionUnix.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=227740
+
+ Reviewed by Žan Doberšek.
+
+ In order to share AHardwareBuffer handles via IPC we need to use the AHardwareBuffer_sendHandleToUnixSocket()
+ and AHardwareBuffer_recvHandleFromUnixSocket() functions. This is not currently compatible with the Attachment
+ API used in UnixConnection, as those functions use custom messaging into the socked fd.
+
+ This patch adds a CustomWriterType Attachment that allows custom messaging going into the socket fd.
+
+ * Platform/IPC/unix/ConnectionUnix.cpp:
+
2021-08-08 Wenson Hsieh <wenson_hs...@apple.com>
caret-color does not work on first click in ios
Modified: trunk/Source/WebKit/Platform/IPC/Attachment.h (280768 => 280769)
--- trunk/Source/WebKit/Platform/IPC/Attachment.h 2021-08-09 02:09:10 UTC (rev 280768)
+++ trunk/Source/WebKit/Platform/IPC/Attachment.h 2021-08-09 09:58:22 UTC (rev 280769)
@@ -35,6 +35,11 @@
#include <windows.h>
#endif
+#if USE(UNIX_DOMAIN_SOCKETS)
+#include <wtf/Function.h>
+#include <wtf/Variant.h>
+#endif
+
namespace IPC {
class Decoder;
@@ -49,6 +54,7 @@
#if USE(UNIX_DOMAIN_SOCKETS)
SocketType,
MappedMemoryType,
+ CustomWriterType,
#elif OS(DARWIN)
MachPortType
#endif
@@ -60,6 +66,11 @@
Attachment(int fileDescriptor, size_t);
Attachment(int fileDescriptor);
~Attachment();
+
+ using SocketDescriptor = int;
+ using CustomWriterFunc = WTF::Function<void(SocketDescriptor)>;
+ using CustomWriter = Variant<CustomWriterFunc, SocketDescriptor>;
+ Attachment(CustomWriter&&);
#elif OS(DARWIN)
Attachment(mach_port_name_t, mach_msg_type_name_t disposition);
#elif OS(WINDOWS)
@@ -75,6 +86,7 @@
int releaseFileDescriptor() { int temp = m_fileDescriptor; m_fileDescriptor = -1; return temp; }
int fileDescriptor() const { return m_fileDescriptor; }
+ const CustomWriter& customWriter() const { return m_customWriter; }
#elif OS(DARWIN)
void release();
@@ -94,6 +106,7 @@
#if USE(UNIX_DOMAIN_SOCKETS)
int m_fileDescriptor { -1 };
size_t m_size;
+ CustomWriter m_customWriter;
#elif OS(DARWIN)
mach_port_name_t m_port { 0 };
mach_msg_type_name_t m_disposition { 0 };
Modified: trunk/Source/WebKit/Platform/IPC/unix/AttachmentUnix.cpp (280768 => 280769)
--- trunk/Source/WebKit/Platform/IPC/unix/AttachmentUnix.cpp 2021-08-09 02:09:10 UTC (rev 280768)
+++ trunk/Source/WebKit/Platform/IPC/unix/AttachmentUnix.cpp 2021-08-09 09:58:22 UTC (rev 280769)
@@ -49,6 +49,7 @@
: m_type(attachment.m_type)
, m_fileDescriptor(attachment.m_fileDescriptor)
, m_size(attachment.m_size)
+ , m_customWriter(WTFMove(attachment.m_customWriter))
{
attachment.m_type = Uninitialized;
attachment.m_fileDescriptor = -1;
@@ -55,6 +56,14 @@
attachment.m_size = 0;
}
+Attachment::Attachment(CustomWriter&& writer)
+ : m_type(CustomWriterType)
+ , m_fileDescriptor(-1)
+ , m_size(0)
+ , m_customWriter(WTFMove(writer))
+{
+}
+
Attachment& Attachment::operator=(Attachment&& attachment)
{
m_type = attachment.m_type;
@@ -63,6 +72,7 @@
attachment.m_fileDescriptor = -1;
m_size = attachment.m_size;
attachment.m_size = 0;
+ m_customWriter = WTFMove(attachment.m_customWriter);
return *this;
}
Modified: trunk/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp (280768 => 280769)
--- trunk/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp 2021-08-09 02:09:10 UTC (rev 280768)
+++ trunk/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp 2021-08-09 09:58:22 UTC (rev 280769)
@@ -206,6 +206,9 @@
fd = m_fileDescriptors[fdIndex++];
attachments[attachmentCount - i - 1] = Attachment(fd);
break;
+ case Attachment::CustomWriterType:
+ attachments[attachmentCount - i - 1] = Attachment(Attachment::CustomWriter(m_socketDescriptor));
+ break;
case Attachment::Uninitialized:
attachments[attachmentCount - i - 1] = Attachment();
default:
@@ -473,6 +476,7 @@
Vector<AttachmentInfo> attachmentInfo;
MallocPtr<char> attachmentFDBuffer;
+ bool hasCustomWriterAttachments { false };
auto& attachments = outputMessage.attachments();
if (!attachments.isEmpty()) {
@@ -514,6 +518,9 @@
} else
attachmentInfo[i].setNull();
break;
+ case Attachment::CustomWriterType:
+ hasCustomWriterAttachments = true;
+ break;
case Attachment::Uninitialized:
default:
break;
@@ -581,6 +588,16 @@
WTFLogAlways("Error sending IPC message: %s", strerror(errno));
return false;
}
+
+ if (hasCustomWriterAttachments) {
+ for (auto& attachment : attachments) {
+ if (attachment.type() == Attachment::CustomWriterType) {
+ ASSERT(WTF::holds_alternative<Attachment::CustomWriterFunc>(attachment.customWriter()));
+ WTF::get<Attachment::CustomWriterFunc>(attachment.customWriter())(m_socketDescriptor);
+ }
+ }
+ }
+
return true;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes