Skip to content
Permalink
Browse files
2011-04-19 Anders Carlsson <andersca@apple.com>
        Reviewed by Alexey Proskuryakov.

        Replace the didFailToSendSyncMessage Connection::Client function with a flag
        https://bugs.webkit.org/show_bug.cgi?id=58923

        * Platform/CoreIPC/Connection.cpp:
        (CoreIPC::Connection::Connection):
        Initialize m_shouldExitOnSyncMessageSendFailure to false.

        (CoreIPC::Connection::setShouldExitOnSyncMessageSendFailure):
        Set m_didCloseOnConnectionWorkQueueCallback.

        (CoreIPC::Connection::sendSyncMessage):
        Call didFailToSendSyncMessage if we fail to send the sync message for some reason.

        (CoreIPC::Connection::didFailToSendSyncMessage):
        if m_shouldExitOnSyncMessageSendFailure is true, exit.

        * Platform/CoreIPC/Connection.h:
        Remove didFailToSendSyncMessage from Connection::Client.

        * PluginProcess/PluginProcess.cpp:
        * PluginProcess/PluginProcess.h:
        Remove didFailToSendSyncMessage.

        * WebProcess/WebProcess.cpp:
        (WebKit::WebProcess::initialize):
        * WebProcess/WebProcess.h:
        Remove didFailToSendSyncMessage. Call setShouldExitOnSyncMessageSendFailure on our
        UI process connection.


Canonical link: https://commits.webkit.org/74028@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@84288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Apr 19, 2011
1 parent 9543635 commit a472aaf1dd1f75132b1540d710ad9f1faefed035
@@ -1,3 +1,36 @@
2011-04-19 Anders Carlsson <andersca@apple.com>

Reviewed by Alexey Proskuryakov.

Replace the didFailToSendSyncMessage Connection::Client function with a flag
https://bugs.webkit.org/show_bug.cgi?id=58923

* Platform/CoreIPC/Connection.cpp:
(CoreIPC::Connection::Connection):
Initialize m_shouldExitOnSyncMessageSendFailure to false.

(CoreIPC::Connection::setShouldExitOnSyncMessageSendFailure):
Set m_didCloseOnConnectionWorkQueueCallback.

(CoreIPC::Connection::sendSyncMessage):
Call didFailToSendSyncMessage if we fail to send the sync message for some reason.

(CoreIPC::Connection::didFailToSendSyncMessage):
if m_shouldExitOnSyncMessageSendFailure is true, exit.

* Platform/CoreIPC/Connection.h:
Remove didFailToSendSyncMessage from Connection::Client.

* PluginProcess/PluginProcess.cpp:
* PluginProcess/PluginProcess.h:
Remove didFailToSendSyncMessage.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initialize):
* WebProcess/WebProcess.h:
Remove didFailToSendSyncMessage. Call setShouldExitOnSyncMessageSendFailure on our
UI process connection.

2011-04-19 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.
@@ -197,6 +197,7 @@ Connection::Connection(Identifier identifier, bool isServer, Client* client, Run
, m_isServer(isServer)
, m_syncRequestID(0)
, m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(false)
, m_shouldExitOnSyncMessageSendFailure(false)
, m_didCloseOnConnectionWorkQueueCallback(0)
, m_isConnected(false)
, m_connectionQueue("com.apple.CoreIPC.ReceiveQueue")
@@ -227,6 +228,13 @@ void Connection::setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcess
m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage = flag;
}

void Connection::setShouldExitOnSyncMessageSendFailure(bool shouldExitOnSyncMessageSendFailure)
{
ASSERT(!m_isConnected);

m_shouldExitOnSyncMessageSendFailure = shouldExitOnSyncMessageSendFailure;
}

void Connection::setDidCloseOnConnectionWorkQueueCallback(DidCloseOnConnectionWorkQueueCallback callback)
{
ASSERT(!m_isConnected);
@@ -358,14 +366,16 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin
// We only allow sending sync messages from the client run loop.
ASSERT(RunLoop::current() == m_clientRunLoop);

if (!isValid())
if (!isValid()) {
didFailToSendSyncMessage();
return 0;

}

// Push the pending sync reply information on our stack.
{
MutexLocker locker(m_syncReplyStateMutex);
if (!m_shouldWaitForSyncReplies) {
m_client->didFailToSendSyncMessage(this);
didFailToSendSyncMessage();
return 0;
}

@@ -387,8 +397,8 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin
m_pendingSyncReplies.removeLast();
}

if (!reply && m_client)
m_client->didFailToSendSyncMessage(this);
if (!reply)
didFailToSendSyncMessage();

return reply.release();
}
@@ -592,6 +602,14 @@ void Connection::dispatchSyncMessage(MessageID messageID, ArgumentDecoder* argum
sendSyncReply(replyEncoder);
}

void Connection::didFailToSendSyncMessage()
{
if (!m_shouldExitOnSyncMessageSendFailure)
return;

exit(0);
}

void Connection::enqueueIncomingMessage(IncomingMessage& incomingMessage)
{
MutexLocker locker(m_incomingMessagesLock);
@@ -93,7 +93,6 @@ class Connection : public ThreadSafeRefCounted<Connection> {
public:
virtual void didClose(Connection*) = 0;
virtual void didReceiveInvalidMessage(Connection*, MessageID) = 0;
virtual void didFailToSendSyncMessage(Connection*) { }

#if PLATFORM(WIN)
virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply() = 0;
@@ -120,6 +119,7 @@ class Connection : public ThreadSafeRefCounted<Connection> {
#endif

void setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(bool);
void setShouldExitOnSyncMessageSendFailure(bool shouldExitOnSyncMessageSendFailure);

// The set callback will be called on the connection work queue when the connection is closed,
// before didCall is called on the client thread. Must be called before the connection is opened.
@@ -216,6 +216,7 @@ class Connection : public ThreadSafeRefCounted<Connection> {
void dispatchMessage(IncomingMessage&);
void dispatchMessages();
void dispatchSyncMessage(MessageID, ArgumentDecoder*);
void didFailToSendSyncMessage();

// Can be called on any thread.
void enqueueIncomingMessage(IncomingMessage&);
@@ -225,6 +226,7 @@ class Connection : public ThreadSafeRefCounted<Connection> {
uint64_t m_syncRequestID;

bool m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage;
bool m_shouldExitOnSyncMessageSendFailure;
DidCloseOnConnectionWorkQueueCallback m_didCloseOnConnectionWorkQueueCallback;

bool m_isConnected;
@@ -124,13 +124,6 @@ void PluginProcess::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::Mess
{
}

NO_RETURN void PluginProcess::didFailToSendSyncMessage(CoreIPC::Connection*)
{
// We were making a synchronous call to a web process that doesn't exist any more.
// Callers are unlikely to be prepared for an error like this, so it's best to exit immediately.
exit(0);
}

void PluginProcess::initializePluginProcess(const PluginProcessCreationParameters& parameters)
{
ASSERT(!m_pluginModule);
@@ -71,7 +71,6 @@ class PluginProcess : ChildProcess {
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
virtual void didClose(CoreIPC::Connection*);
virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
virtual void didFailToSendSyncMessage(CoreIPC::Connection*);

// Message handlers.
void didReceivePluginProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
@@ -148,6 +148,7 @@ void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, Ru

m_connection = CoreIPC::Connection::createClientConnection(serverIdentifier, this, runLoop);
m_connection->setDidCloseOnConnectionWorkQueueCallback(didCloseOnConnectionWorkQueue);
m_connection->setShouldExitOnSyncMessageSendFailure(true);

m_connection->open();

@@ -665,13 +666,6 @@ void WebProcess::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::Message
// we'll let it slide.
}

NO_RETURN void WebProcess::didFailToSendSyncMessage(CoreIPC::Connection*)
{
// We were making a synchronous call to a UI process that doesn't exist any more.
// Callers are unlikely to be prepared for an error like this, so it's best to exit immediately.
exit(0);
}

WebFrame* WebProcess::webFrame(uint64_t frameID) const
{
return m_frameMap.get(frameID);
@@ -172,7 +172,6 @@ class WebProcess : public ChildProcess {
CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
void didClose(CoreIPC::Connection*);
void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
NO_RETURN void didFailToSendSyncMessage(CoreIPC::Connection*);
#if PLATFORM(WIN)
Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply();
#endif

0 comments on commit a472aaf

Please sign in to comment.