Changeset 160308 in webkit


Ignore:
Timestamp:
Dec 9, 2013 4:28:44 AM (10 years ago)
Author:
svillar@igalia.com
Message:

[WK2] Add UNIX_DOMAIN_SOCKETS specific bits for supporting NetworkProcess
https://bugs.webkit.org/show_bug.cgi?id=110093

Reviewed by Martin Robinson.

Original patch by Balazs Kelemen <kbalazs@webkit.org>.

Adds the UNIX specific bits to support connections to the
NetworkProcess. Since the process of creating the pair of sockets
is exactly the same as in the PluginProcess, I've decided to
refactor it in ConnectionUnix::createPlatformConnection(). This
can be reused later to create a cross-platform solution and remove
all the ifdefs (see bug 110978).

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::createNetworkConnectionToWebProcess):

  • Platform/CoreIPC/Connection.h:
  • Platform/CoreIPC/unix/ConnectionUnix.cpp:

(CoreIPC::Connection::createPlatformConnection):

  • PluginProcess/PluginProcess.cpp:

(WebKit::PluginProcess::createWebProcessConnection):

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch):
(WebKit::NetworkProcessProxy::didCreateNetworkConnectionToWebProcess):

  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::ensureNetworkProcessConnection):

Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160307 r160308  
     12013-12-09  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [WK2] Add UNIX_DOMAIN_SOCKETS specific bits for supporting NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=110093
     5
     6        Reviewed by Martin Robinson.
     7
     8        Original patch by Balazs Kelemen <kbalazs@webkit.org>.
     9
     10        Adds the UNIX specific bits to support connections to the
     11        NetworkProcess. Since the process of creating the pair of sockets
     12        is exactly the same as in the PluginProcess, I've decided to
     13        refactor it in ConnectionUnix::createPlatformConnection(). This
     14        can be reused later to create a cross-platform solution and remove
     15        all the ifdefs (see bug 110978).
     16
     17        * NetworkProcess/NetworkProcess.cpp:
     18        (WebKit::NetworkProcess::createNetworkConnectionToWebProcess):
     19        * Platform/CoreIPC/Connection.h:
     20        * Platform/CoreIPC/unix/ConnectionUnix.cpp:
     21        (CoreIPC::Connection::createPlatformConnection):
     22        * PluginProcess/PluginProcess.cpp:
     23        (WebKit::PluginProcess::createWebProcessConnection):
     24        * UIProcess/Network/NetworkProcessProxy.cpp:
     25        (WebKit::NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch):
     26        (WebKit::NetworkProcessProxy::didCreateNetworkConnectionToWebProcess):
     27        * WebProcess/WebProcess.cpp:
     28        (WebKit::WebProcess::ensureNetworkProcessConnection):
     29
    1302013-12-09  Kwang Yul Seo  <skyul@company100.net>
    231
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp

    r160290 r160308  
    200200    CoreIPC::Attachment clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
    201201    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidCreateNetworkConnectionToWebProcess(clientPort), 0);
     202#elif USE(UNIX_DOMAIN_SOCKETS)
     203    CoreIPC::Connection::SocketPair socketPair = CoreIPC::Connection::createPlatformConnection();
     204
     205    RefPtr<NetworkConnectionToWebProcess> connection = NetworkConnectionToWebProcess::create(socketPair.server);
     206    m_webProcessConnections.append(connection.release());
     207
     208    CoreIPC::Attachment clientSocket(socketPair.client);
     209    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidCreateNetworkConnectionToWebProcess(clientSocket), 0);
    202210#else
    203211    notImplemented();
  • trunk/Source/WebKit2/Platform/CoreIPC/Connection.h

    r159727 r160308  
    117117    typedef int Identifier;
    118118    static bool identifierIsNull(Identifier identifier) { return !identifier; }
     119
     120    struct SocketPair {
     121        int client;
     122        int server;
     123    };
     124
     125    static Connection::SocketPair createPlatformConnection();
    119126#endif
    120127
  • trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp

    r160162 r160308  
    4444#endif
    4545
     46#ifdef SOCK_SEQPACKET
     47#define SOCKET_TYPE SOCK_SEQPACKET
     48#else
     49#if PLATFORM(GTK)
     50#define SOCKET_TYPE SOCK_STREAM
     51#else
     52#define SOCKET_TYPE SOCK_DGRAM
     53#endif
     54#endif // SOCK_SEQPACKET
     55
    4656namespace CoreIPC {
    4757
     
    507517}
    508518
     519Connection::SocketPair Connection::createPlatformConnection()
     520{
     521    int sockets[2];
     522    RELEASE_ASSERT(socketpair(AF_UNIX, SOCKET_TYPE, 0, sockets) != -1);
     523
     524    // Don't expose the child socket to the parent process.
     525    while (fcntl(sockets[1], F_SETFD, FD_CLOEXEC)  == -1)
     526        RELEASE_ASSERT(errno != EINTR);
     527
     528    // Don't expose the parent socket to potential future children.
     529    while (fcntl(sockets[0], F_SETFD, FD_CLOEXEC) == -1)
     530        RELEASE_ASSERT(errno != EINTR);
     531
     532    SocketPair socketPair = { sockets[0], sockets[1] };
     533    return socketPair;
     534}
     535
    509536} // namespace CoreIPC
  • trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp

    r159248 r160308  
    4545#endif
    4646
    47 #if USE(UNIX_DOMAIN_SOCKETS)
    48 #include <errno.h>
    49 #include <fcntl.h>
    50 #include <sys/resource.h>
    51 #include <sys/socket.h>
    52 #include <unistd.h>
    53 #include <wtf/UniStdExtras.h>
    54 
    55 #ifdef SOCK_SEQPACKET
    56 #define SOCKET_TYPE SOCK_SEQPACKET
    57 #else
    58 #if PLATFORM(GTK)
    59 #define SOCKET_TYPE SOCK_STREAM
    60 #else
    61 #define SOCKET_TYPE SOCK_DGRAM
    62 #endif
    63 #endif // SOCK_SEQPACKET
    64 #endif // USE(UNIX_DOMAIN_SOCKETS)
    65 
    6647using namespace WebCore;
    6748
     
    184165    parentProcessConnection()->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientPort, m_supportsAsynchronousPluginInitialization), 0);
    185166#elif USE(UNIX_DOMAIN_SOCKETS)
    186     int sockets[2];
    187     if (socketpair(AF_UNIX, SOCKET_TYPE, 0, sockets) == -1) {
    188         ASSERT_NOT_REACHED();
    189         return;
    190     }
    191 
    192     // Don't expose the plugin process socket to the web process.
    193     while (fcntl(sockets[1], F_SETFD, FD_CLOEXEC)  == -1) {
    194         if (errno != EINTR) {
    195             ASSERT_NOT_REACHED();
    196             closeWithRetry(sockets[0]);
    197             closeWithRetry(sockets[1]);
    198             return;
    199         }
    200     }
    201 
    202     // Don't expose the web process socket to possible future web processes.
    203     while (fcntl(sockets[0], F_SETFD, FD_CLOEXEC) == -1) {
    204         if (errno != EINTR) {
    205             ASSERT_NOT_REACHED();
    206             closeWithRetry(sockets[0]);
    207             closeWithRetry(sockets[1]);
    208             return;
    209         }
    210     }
    211 
    212     RefPtr<WebProcessConnection> connection = WebProcessConnection::create(sockets[1]);
     167    CoreIPC::Connection::SocketPair socketPair = CoreIPC::Connection::createPlatformConnection();
     168
     169    RefPtr<WebProcessConnection> connection = WebProcessConnection::create(socketPair.server);
    213170    m_webProcessConnections.append(connection.release());
    214171
    215     CoreIPC::Attachment clientSocket(sockets[0]);
     172    CoreIPC::Attachment clientSocket(socketPair.client);
    216173    parentProcessConnection()->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientSocket, m_supportsAsynchronousPluginInitialization), 0);
    217174#else
  • trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp

    r160290 r160308  
    112112#if PLATFORM(MAC)
    113113        reply->send(CoreIPC::Attachment(0, MACH_MSG_TYPE_MOVE_SEND));
     114#elif USE(UNIX_DOMAIN_SOCKETS)
     115        reply->send(CoreIPC::Attachment());
    114116#else
    115117        notImplemented();
     
    162164#if PLATFORM(MAC)
    163165    reply->send(CoreIPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND));
     166#elif USE(UNIX_DOMAIN_SOCKETS)
     167    reply->send(connectionIdentifier);
    164168#else
    165169    notImplemented();
  • trunk/Source/WebKit2/WebProcess/WebProcess.cpp

    r160136 r160308  
    373373#if PLATFORM(MAC)
    374374    CoreIPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.port());
    375     if (CoreIPC::Connection::identifierIsNull(connectionIdentifier))
    376         return;
     375#elif USE(UNIX_DOMAIN_SOCKETS)
     376    CoreIPC::Connection::Identifier connectionIdentifier = encodedConnectionIdentifier.releaseFileDescriptor();
    377377#else
    378378    ASSERT_NOT_REACHED();
    379379#endif
     380    if (CoreIPC::Connection::identifierIsNull(connectionIdentifier))
     381        return;
    380382    m_networkProcessConnection = NetworkProcessConnection::create(connectionIdentifier);
    381383}
Note: See TracChangeset for help on using the changeset viewer.