Title: [165745] trunk/Source/WebKit2
Revision
165745
Author
[email protected]
Date
2014-03-17 11:20:28 -0700 (Mon, 17 Mar 2014)

Log Message

[GTK] Don't busy loop when the socket is full
https://bugs.webkit.org/show_bug.cgi?id=129802

Patch by Giovanni Campagna <[email protected]> on 2014-03-17
Reviewed by Carlos Garcia Campos.

When the socket is full and we see EAGAIN or EWOULDBLOCK
(because the socket is non blocking), don't busy loop by
tring to write again, instead poll() until the socket
becomes writable.

* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::sendOutgoingMessage):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (165744 => 165745)


--- trunk/Source/WebKit2/ChangeLog	2014-03-17 17:50:16 UTC (rev 165744)
+++ trunk/Source/WebKit2/ChangeLog	2014-03-17 18:20:28 UTC (rev 165745)
@@ -1,3 +1,18 @@
+2014-03-17  Giovanni Campagna  <[email protected]>
+
+        [GTK] Don't busy loop when the socket is full
+        https://bugs.webkit.org/show_bug.cgi?id=129802
+
+        Reviewed by Carlos Garcia Campos.
+
+        When the socket is full and we see EAGAIN or EWOULDBLOCK
+        (because the socket is non blocking), don't busy loop by
+        tring to write again, instead poll() until the socket
+        becomes writable.
+
+        * Platform/IPC/unix/ConnectionUnix.cpp:
+        (IPC::Connection::sendOutgoingMessage):
+
 2014-03-17  Martin Robinson  <[email protected]>
 
         [GTK][CMake] Ensure that HAVE_GTK_UNIX_PRINTING is defined when appropriate

Modified: trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp (165744 => 165745)


--- trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp	2014-03-17 17:50:16 UTC (rev 165744)
+++ trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp	2014-03-17 18:20:28 UTC (rev 165745)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <poll.h>
 #include <wtf/Assertions.h>
 #include <wtf/Functional.h>
 #include <wtf/StdLibExtras.h>
@@ -522,9 +523,18 @@
 
     int bytesSent = 0;
     while ((bytesSent = sendmsg(m_socketDescriptor, &message, 0)) == -1) {
-        if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
+        if (errno == EINTR)
             continue;
+        if (errno == EAGAIN || errno == EWOULDBLOCK) {
+            struct pollfd pollfd;
 
+            pollfd.fd = m_socketDescriptor;
+            pollfd.events = POLLOUT;
+            pollfd.revents = 0;
+            poll(&pollfd, 1, -1);
+            continue;
+        }
+
         WTFLogAlways("Error sending IPC message: %s", strerror(errno));
         return false;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to