Changeset 70085 in webkit


Ignore:
Timestamp:
Oct 19, 2010 2:11:29 PM (14 years ago)
Author:
andersca@apple.com
Message:

Stop waiting for sync replies if the connection is closed
https://bugs.webkit.org/show_bug.cgi?id=47930

Reviewed by Adam Roben.

  • Platform/CoreIPC/Connection.cpp:

(CoreIPC::Connection::Connection):
Initialize m_shouldWaitForSyncReplies to true.

(CoreIPC::Connection::sendSyncMessage):
Don't attempt to send a message if m_shouldWaitForSyncReplies is false.

(CoreIPC::Connection::waitForSyncReply):
Return if m_shouldWaitForSyncReplies was set to false.

(CoreIPC::Connection::connectionDidClose):
Set m_shouldWaitForSyncReplies to true and signal the semaphore.

  • Platform/CoreIPC/Connection.h:
Location:
trunk/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r70067 r70085  
     12010-10-19  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Stop waiting for sync replies if the connection is closed
     6        https://bugs.webkit.org/show_bug.cgi?id=47930
     7
     8        * Platform/CoreIPC/Connection.cpp:
     9        (CoreIPC::Connection::Connection):
     10        Initialize m_shouldWaitForSyncReplies to true.
     11
     12        (CoreIPC::Connection::sendSyncMessage):
     13        Don't attempt to send a message if m_shouldWaitForSyncReplies is false.
     14
     15        (CoreIPC::Connection::waitForSyncReply):
     16        Return if m_shouldWaitForSyncReplies was set to false.
     17
     18        (CoreIPC::Connection::connectionDidClose):
     19        Set m_shouldWaitForSyncReplies to true and signal the semaphore.
     20
     21        * Platform/CoreIPC/Connection.h:
     22
    1232010-10-19  Adam Roben  <aroben@apple.com>
    224
  • trunk/WebKit2/Platform/CoreIPC/Connection.cpp

    r69584 r70085  
    5252    , m_connectionQueue("com.apple.CoreIPC.ReceiveQueue")
    5353    , m_clientRunLoop(clientRunLoop)
     54    , m_shouldWaitForSyncReplies(true)
    5455{
    5556    ASSERT(m_client);
     
    166167    // Push the pending sync reply information on our stack.
    167168    {
    168         MutexLocker locker(m_pendingSyncRepliesMutex);
     169        MutexLocker locker(m_syncReplyStateMutex);
     170        if (!m_shouldWaitForSyncReplies)
     171            return 0;
     172
    169173        m_pendingSyncReplies.append(PendingSyncReply(syncRequestID));
    170174    }
     
    178182    // Finally, pop the pending sync reply information.
    179183    {
    180         MutexLocker locker(m_pendingSyncRepliesMutex);
     184        MutexLocker locker(m_syncReplyStateMutex);
    181185        ASSERT(m_pendingSyncReplies.last().syncRequestID == syncRequestID);
    182186        m_pendingSyncReplies.removeLast();
     
    193197    while (!timedOut) {
    194198        {
    195             MutexLocker locker(m_pendingSyncRepliesMutex);
     199            MutexLocker locker(m_syncReplyStateMutex);
    196200
    197201            // First, check if there is a sync reply at the top of the stack.
     
    201205            ASSERT(pendingSyncReply.syncRequestID == syncRequestID);
    202206           
    203             // We found the sync reply, return it.
    204             if (pendingSyncReply.didReceiveReply)
     207            // We found the sync reply, or the connection was closed.
     208            if (pendingSyncReply.didReceiveReply || !m_shouldWaitForSyncReplies)
    205209                return pendingSyncReply.releaseReplyDecoder();
    206210        }
     
    218222    // Check if this is a sync reply.
    219223    if (messageID == MessageID(CoreIPCMessage::SyncMessageReply)) {
    220         MutexLocker locker(m_pendingSyncRepliesMutex);
     224        MutexLocker locker(m_syncReplyStateMutex);
    221225        ASSERT(!m_pendingSyncReplies.isEmpty());
    222226
     
    254258    // The connection is now invalid.
    255259    platformInvalidate();
    256    
     260
     261    {
     262        MutexLocker locker(m_syncReplyStateMutex);
     263
     264        ASSERT(m_shouldWaitForSyncReplies);
     265        m_shouldWaitForSyncReplies = false;
     266
     267        if (!m_pendingSyncReplies.isEmpty())
     268            m_waitForSyncReplySemaphore.signal();
     269    }
     270
    257271    m_clientRunLoop->scheduleWork(WorkItem::create(this, &Connection::dispatchConnectionDidClose));
    258272}
  • trunk/WebKit2/Platform/CoreIPC/Connection.h

    r69584 r70085  
    229229    BinarySemaphore m_waitForSyncReplySemaphore;
    230230
    231     Mutex m_pendingSyncRepliesMutex;
     231    Mutex m_syncReplyStateMutex;
     232    bool m_shouldWaitForSyncReplies;
    232233    Vector<PendingSyncReply> m_pendingSyncReplies;
    233234
Note: See TracChangeset for help on using the changeset viewer.