WebCore icon database appears to leak sudden termination assertions
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jan 2014 20:28:23 +0000 (20:28 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jan 2014 20:28:23 +0000 (20:28 +0000)
commit98e1e3cf11e9c55db3f1fb388378ece2cf8492ff
tree46196dd27da5f19675ab6bec94b4fef5475ba284
parentdfce08f51480304a4e30e55dee857217626915a9
WebCore icon database appears to leak sudden termination assertions
<https://webkit.org/b/126971> / <rdar://problem/15808797>

Introduce an RAII wrapper around disableSuddenTermination / enableSuddenTermination
and adopt it in IconDatabase to address the incorrect management of sudden termination.

IconDatabase now owns up to two SuddenTerminationDisabler objects. One ensures that
sudden termination is disabled while we're waiting on the sync timer to fire. The second
ensures that sudden termination is disabled while we're waiting on the sync thread to
process any pending work.

Reviewed by Alexey Proskuryakov.

* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::IconDatabase):
(WebCore::IconDatabase::wakeSyncThread): Disable sudden termination until the sync thread
has finished this unit of work.
(WebCore::IconDatabase::scheduleOrDeferSyncTimer): Disable sudden termination until the
sync timer has fired.
(WebCore::IconDatabase::syncTimerFired): Clear the member variable to reenable sudden termination.
(WebCore::IconDatabase::syncThreadMainLoop): Taken ownership of the SuddenTerminationDisabler
instance when we start processing a unit of work. Discard the object when our work is complete.
* loader/icon/IconDatabase.h:
* platform/SuddenTermination.h:
(WebCore::SuddenTerminationDisabler::SuddenTerminationDisabler): Disable sudden termination when created.
(WebCore::SuddenTerminationDisabler::~SuddenTerminationDisabler): Enable it when destroyed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161995 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/loader/icon/IconDatabase.cpp
Source/WebCore/loader/icon/IconDatabase.h
Source/WebCore/platform/SuddenTermination.h