Changeset 181257 in webkit


Ignore:
Timestamp:
Mar 8, 2015 9:15:42 PM (9 years ago)
Author:
Brent Fulgham
Message:

[Win] WTF::WorkQueue does not balance ref/deref properly
https://bugs.webkit.org/show_bug.cgi?id=142471

Reviewed by Antti Koivisto.

Source/WTF:

Make sure we deref the count when we execute a function in the
WorkQueue.

  • wtf/win/WorkQueueWin.cpp:

(WTF::WorkQueue::performWorkOnRegisteredWorkThread):

Tools:

  • TestWebKitAPI/Tests/WTF/WorkQueue.cpp:

(TestWebKitAPI::TEST): Check that the refcount is correct.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r181220 r181257  
     12015-03-08  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Win] WTF::WorkQueue does not balance ref/deref properly
     4        https://bugs.webkit.org/show_bug.cgi?id=142471
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Make sure we deref the count when we execute a function in the
     9        WorkQueue.
     10
     11        * wtf/win/WorkQueueWin.cpp:
     12        (WTF::WorkQueue::performWorkOnRegisteredWorkThread):
     13
    1142015-03-07  Brent Fulgham  <bfulgham@apple.com>
    215
  • trunk/Source/WTF/wtf/win/WorkQueueWin.cpp

    r181220 r181257  
    8383        // Allow more work to be scheduled while we're not using the queue directly.
    8484        m_workItemQueueLock.unlock();
    85         for (auto& workItem : workItemQueue)
     85        for (auto& workItem : workItemQueue) {
    8686            workItem->function()();
     87            deref();
     88        }
    8789        m_workItemQueueLock.lock();
    8890    }
  • trunk/Tools/ChangeLog

    r181255 r181257  
     12015-03-08  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Win] WTF::WorkQueue does not balance ref/deref properly
     4        https://bugs.webkit.org/show_bug.cgi?id=142471
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * TestWebKitAPI/Tests/WTF/WorkQueue.cpp:
     9        (TestWebKitAPI::TEST): Check that the refcount is correct.
     10
    1112015-03-08  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp

    r181254 r181257  
    5454
    5555    auto queue = WorkQueue::create("com.apple.WebKit.Test.simple");
    56    
     56    int initialRefCount = queue->refCount();
     57    EXPECT_EQ(1, initialRefCount);
     58
    5759    MutexLocker locker(m_lock);
    5860    queue->dispatch([&](void) {
     
    6062        calledSimpleTest = true;
    6163    });
    62    
     64
    6365    queue->dispatch([&](void) {
    6466        m_functionCallOrder.append(longTestLabel);
     
    7981    });
    8082
     83    EXPECT_GT(queue->refCount(), 1);
     84
    8185    m_testCompleted.wait(m_lock);
     86
     87    EXPECT_EQ(1, queue->refCount());
    8288
    8389    EXPECT_TRUE(calledSimpleTest);
     
    8591    EXPECT_TRUE(calledThirdTest);
    8692
    87     EXPECT_EQ(m_functionCallOrder.size(), static_cast<size_t>(3));
     93    EXPECT_EQ(static_cast<size_t>(3), m_functionCallOrder.size());
    8894    EXPECT_STREQ(simpleTestLabel, m_functionCallOrder[0].c_str());
    8995    EXPECT_STREQ(longTestLabel, m_functionCallOrder[1].c_str());
     
    104110    auto queue2 = WorkQueue::create("com.apple.WebKit.Test.twoQueues2");
    105111
     112    int initialQueue1RefCount = queue1->refCount();
     113    int initialQueue2RefCount = queue2->refCount();
     114    EXPECT_EQ(1, initialQueue1RefCount);
     115    EXPECT_EQ(1, initialQueue2RefCount);
     116
    106117    MutexLocker locker(m_lock);
    107118   
     
    133144    EXPECT_FALSE(calledLongTest);
    134145    EXPECT_TRUE(calledThirdTest);
     146    EXPECT_EQ(1, queue1->refCount());
    135147
    136148    m_testQueue2Completed.wait(m_lock);
     
    139151    EXPECT_TRUE(calledLongTest);
    140152    EXPECT_TRUE(calledThirdTest);
    141 
    142     EXPECT_EQ(m_functionCallOrder.size(), static_cast<size_t>(3));
     153    EXPECT_EQ(1, queue2->refCount());
     154
     155    EXPECT_EQ(static_cast<size_t>(3), m_functionCallOrder.size());
    143156    EXPECT_STREQ(simpleTestLabel, m_functionCallOrder[0].c_str());
    144157    EXPECT_STREQ(thirdTestLabel, m_functionCallOrder[1].c_str());
     
    183196    EXPECT_TRUE(calledDispatchAfterTest);
    184197
    185     EXPECT_EQ(m_functionCallOrder.size(), static_cast<size_t>(2));
     198    EXPECT_EQ(static_cast<size_t>(2), m_functionCallOrder.size());
    186199    EXPECT_STREQ(simpleTestLabel, m_functionCallOrder[0].c_str());
    187200    EXPECT_STREQ(dispatchAfterLabel, m_functionCallOrder[1].c_str());
Note: See TracChangeset for help on using the changeset viewer.