⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 236988 in webkit


Ignore:
Timestamp:
Oct 9, 2018, 4:25:46 PM (8 years ago)
Author:
Chris Dumez
Message:

Allow behavior when the parent process IPC::Connection closes to be overridden by ChildProcess subclasses
https://bugs.webkit.org/show_bug.cgi?id=190294

Reviewed by Geoffrey Garen.

Allow behavior when the parent process IPC::Connection closes to be overridden by ChildProcess subclasses.
This will be useful to allow the NetworkProcess to not exit if it still has pending downloads.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::callExitSoon):
(WebKit::NetworkProcess::initializeConnection):

  • NetworkProcess/NetworkProcess.h:
  • PluginProcess/PluginProcess.cpp:

(WebKit::callExit):
(WebKit::PluginProcess::initializeConnection):

  • PluginProcess/PluginProcess.h:
  • Shared/ChildProcess.cpp:

(WebKit::ChildProcess::didClose):
(WebKit::ChildProcess::initialize):
(WebKit::callExitNow): Deleted.
(WebKit::callExitSoon): Deleted.

  • Shared/ChildProcess.h:

(WebKit::ChildProcess::shouldCallExitWhenConnectionIsClosed const): Deleted.

  • WebProcess/WebProcess.cpp:

(WebKit::callExit):
(WebKit::WebProcess::initializeConnection):

Location:
trunk/Source/WebKit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r236984 r236988  
     12018-10-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Allow behavior when the parent process IPC::Connection closes to be overridden by ChildProcess subclasses
     4        https://bugs.webkit.org/show_bug.cgi?id=190294
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Allow behavior when the parent process IPC::Connection closes to be overridden by ChildProcess subclasses.
     9        This will be useful to allow the NetworkProcess to not exit if it still has pending downloads.
     10
     11        * NetworkProcess/NetworkProcess.cpp:
     12        (WebKit::callExitSoon):
     13        (WebKit::NetworkProcess::initializeConnection):
     14        * NetworkProcess/NetworkProcess.h:
     15        * PluginProcess/PluginProcess.cpp:
     16        (WebKit::callExit):
     17        (WebKit::PluginProcess::initializeConnection):
     18        * PluginProcess/PluginProcess.h:
     19        * Shared/ChildProcess.cpp:
     20        (WebKit::ChildProcess::didClose):
     21        (WebKit::ChildProcess::initialize):
     22        (WebKit::callExitNow): Deleted.
     23        (WebKit::callExitSoon): Deleted.
     24        * Shared/ChildProcess.h:
     25        (WebKit::ChildProcess::shouldCallExitWhenConnectionIsClosed const): Deleted.
     26        * WebProcess/WebProcess.cpp:
     27        (WebKit::callExit):
     28        (WebKit::WebProcess::initializeConnection):
     29
    1302018-10-09  Jer Noble  <jer.noble@apple.com>
    231
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r236772 r236988  
    109109using namespace WebCore;
    110110
     111static void callExitSoon(IPC::Connection*)
     112{
     113    // If the connection has been closed and we haven't responded in the main thread for 10 seconds
     114    // the process will exit forcibly.
     115    auto watchdogDelay = 10_s;
     116
     117    WorkQueue::create("com.apple.WebKit.ChildProcess.WatchDogQueue")->dispatchAfter(watchdogDelay, [] {
     118        // We use _exit here since the watchdog callback is called from another thread and we don't want
     119        // global destructors or atexit handlers to be called from this thread while the main thread is busy
     120        // doing its thing.
     121        RELEASE_LOG_ERROR(IPC, "Exiting process early due to unacknowledged closed-connection");
     122        _exit(EXIT_FAILURE);
     123    });
     124}
     125
    111126NetworkProcess& NetworkProcess::singleton()
    112127{
     
    359374{
    360375    ChildProcess::initializeConnection(connection);
     376
     377    // We give a chance for didClose() to get called on the main thread but forcefully call _exit() after a delay
     378    // in case the main thread is unresponsive or didClose() takes too long.
     379    connection->setDidCloseOnConnectionWorkQueueCallback(callExitSoon);
    361380
    362381    for (auto& supplement : m_supplements.values())
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r236485 r236988  
    247247    void initializeConnection(IPC::Connection*) override;
    248248    bool shouldTerminate() override;
    249     bool shouldCallExitWhenConnectionIsClosed() const final { return false; } // We override didClose() and want it to be called.
    250249
    251250    // IPC::Connection::Client
  • trunk/Source/WebKit/PluginProcess/PluginProcess.cpp

    r232176 r236988  
    5353namespace WebKit {
    5454
     55NO_RETURN static void callExit(IPC::Connection*)
     56{
     57    _exit(EXIT_SUCCESS);
     58}
     59
    5560PluginProcess& PluginProcess::singleton()
    5661{
     
    7782    m_pluginPath = parameters.extraInitializationData.get("plugin-path");
    7883    platformInitializeProcess(parameters);
     84}
     85
     86void PluginProcess::initializeConnection(IPC::Connection* connection)
     87{
     88    ChildProcess::initializeConnection(connection);
     89
     90    // We call _exit() directly from the background queue in case the main thread is unresponsive
     91    // and ChildProcess::didClose() does not get called.
     92    connection->setDidCloseOnConnectionWorkQueueCallback(callExit);
    7993}
    8094
  • trunk/Source/WebKit/PluginProcess/PluginProcess.h

    r234910 r236988  
    8383    void initializeProcess(const ChildProcessInitializationParameters&) override;
    8484    void initializeProcessName(const ChildProcessInitializationParameters&) override;
     85    void initializeConnection(IPC::Connection*) override;
    8586    void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) override;
    8687    bool shouldTerminate() override;
  • trunk/Source/WebKit/Shared/ChildProcess.cpp

    r234486 r236988  
    5757void ChildProcess::didClose(IPC::Connection&)
    5858{
    59 }
    60 
    61 NO_RETURN static void callExitNow(IPC::Connection*)
    62 {
    6359    _exit(EXIT_SUCCESS);
    64 }
    65 
    66 static void callExitSoon(IPC::Connection*)
    67 {
    68     // If the connection has been closed and we haven't responded in the main thread for 10 seconds
    69     // the process will exit forcibly.
    70     auto watchdogDelay = 10_s;
    71 
    72     WorkQueue::create("com.apple.WebKit.ChildProcess.WatchDogQueue")->dispatchAfter(watchdogDelay, [] {
    73         // We use _exit here since the watchdog callback is called from another thread and we don't want
    74         // global destructors or atexit handlers to be called from this thread while the main thread is busy
    75         // doing its thing.
    76         RELEASE_LOG_ERROR(IPC, "Exiting process early due to unacknowledged closed-connection");
    77         _exit(EXIT_FAILURE);
    78     });
    7960}
    8061
     
    10081
    10182    m_connection = IPC::Connection::createClientConnection(parameters.connectionIdentifier, *this);
    102     if (shouldCallExitWhenConnectionIsClosed())
    103         m_connection->setDidCloseOnConnectionWorkQueueCallback(callExitNow);
    104     else
    105         m_connection->setDidCloseOnConnectionWorkQueueCallback(callExitSoon);
    106 
    10783    initializeConnection(m_connection.get());
    10884    m_connection->open();
  • trunk/Source/WebKit/Shared/ChildProcess.h

    r235220 r236988  
    9696    virtual void terminate();
    9797
    98     virtual bool shouldCallExitWhenConnectionIsClosed() const { return true; }
    9998    virtual void stopRunLoop();
    10099
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r236959 r236988  
    158158using namespace WebCore;
    159159
     160NO_RETURN static void callExit(IPC::Connection*)
     161{
     162    _exit(EXIT_SUCCESS);
     163}
     164
    160165WebProcess& WebProcess::singleton()
    161166{
     
    227232{
    228233    ChildProcess::initializeConnection(connection);
     234
     235    // We call _exit() directly from the background queue in case the main thread is unresponsive
     236    // and ChildProcess::didClose() does not get called.
     237    connection->setDidCloseOnConnectionWorkQueueCallback(callExit);
    229238
    230239#if !PLATFORM(GTK) && !PLATFORM(WPE)
Note: See TracChangeset for help on using the changeset viewer.