Skip to content

Commit

Permalink
Merge r165745 - [GTK] Don't busy loop when the socket is full
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=129802

Patch by Giovanni Campagna <gcampagna@src.gnome.org> 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):
  • Loading branch information
gcampax authored and carlosgcampos committed Mar 19, 2014
1 parent 43f7717 commit e354499
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,18 @@
2014-03-17 Giovanni Campagna <gcampagna@src.gnome.org>

[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-14 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] WebKit2WebExtension GIR can't be used in vala
Expand Down
12 changes: 11 additions & 1 deletion Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -522,8 +523,17 @@ bool Connection::sendOutgoingMessage(std::unique_ptr<MessageEncoder> encoder)

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;
Expand Down

0 comments on commit e354499

Please sign in to comment.