Title: [101626] trunk/Source/WebCore
- Revision
- 101626
- Author
- [email protected]
- Date
- 2011-11-30 23:59:13 -0800 (Wed, 30 Nov 2011)
Log Message
Move data in IDBPendingTransactionMonitor from static to
ThreadSpecific.
https://bugs.webkit.org/show_bug.cgi?id=73389
IDBPendingTransactionMonitor previously stored transactions in
a static member variable so that they could be aborted if they were
had no work queued up when leaving script execution. That was fine when
IndexedDB could only be used on the main thread, but is insufficient
for IndexedDB on workers. In addition to not being thread-safe, this
caused pending transactions that were created from a worker thread to
abort when the main thread left script execution.
Reviewed by David Levin.
No new tests - IndexedDB worker tests forthcoming.
* storage/IDBPendingTransactionMonitor.cpp:
(WebCore::transactions): Create the TLS. The other methods used to
manage the container's memory lifetime but now we just leak it until
the thread shuts down in the interest of simpler code.
(WebCore::IDBPendingTransactionMonitor::addPendingTransaction):
(WebCore::IDBPendingTransactionMonitor::removePendingTransaction):
(WebCore::IDBPendingTransactionMonitor::abortPendingTransactions):
* storage/IDBPendingTransactionMonitor.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (101625 => 101626)
--- trunk/Source/WebCore/ChangeLog 2011-12-01 07:47:27 UTC (rev 101625)
+++ trunk/Source/WebCore/ChangeLog 2011-12-01 07:59:13 UTC (rev 101626)
@@ -1,3 +1,31 @@
+2011-11-30 David Grogan <[email protected]>
+
+ Move data in IDBPendingTransactionMonitor from static to
+ ThreadSpecific.
+ https://bugs.webkit.org/show_bug.cgi?id=73389
+
+ IDBPendingTransactionMonitor previously stored transactions in
+ a static member variable so that they could be aborted if they were
+ had no work queued up when leaving script execution. That was fine when
+ IndexedDB could only be used on the main thread, but is insufficient
+ for IndexedDB on workers. In addition to not being thread-safe, this
+ caused pending transactions that were created from a worker thread to
+ abort when the main thread left script execution.
+
+ Reviewed by David Levin.
+
+ No new tests - IndexedDB worker tests forthcoming.
+
+ * storage/IDBPendingTransactionMonitor.cpp:
+ (WebCore::transactions): Create the TLS. The other methods used to
+ manage the container's memory lifetime but now we just leak it until
+ the thread shuts down in the interest of simpler code.
+ (WebCore::IDBPendingTransactionMonitor::addPendingTransaction):
+ (WebCore::IDBPendingTransactionMonitor::removePendingTransaction):
+ (WebCore::IDBPendingTransactionMonitor::abortPendingTransactions):
+
+ * storage/IDBPendingTransactionMonitor.h:
+
2011-11-30 Leo Yang <[email protected]>
Upstream platform/network/blackberry/NetworkStateNotifierBlackBerry.cpp
Modified: trunk/Source/WebCore/storage/IDBPendingTransactionMonitor.cpp (101625 => 101626)
--- trunk/Source/WebCore/storage/IDBPendingTransactionMonitor.cpp 2011-12-01 07:47:27 UTC (rev 101625)
+++ trunk/Source/WebCore/storage/IDBPendingTransactionMonitor.cpp 2011-12-01 07:59:13 UTC (rev 101626)
@@ -26,47 +26,44 @@
#include "config.h"
#include "IDBPendingTransactionMonitor.h"
#include "IDBTransactionBackendInterface.h"
+#include <wtf/ThreadSpecific.h>
+using WTF::ThreadSpecific;
+
#if ENABLE(INDEXED_DATABASE)
namespace WebCore {
-Vector<IDBTransactionBackendInterface*>* IDBPendingTransactionMonitor::m_transactions = 0;
+ThreadSpecific<Vector<IDBTransactionBackendInterface*> >& transactions()
+{
+ // FIXME: Move the Vector to ScriptExecutionContext to avoid dealing with
+ // thread-local storage.
+ AtomicallyInitializedStatic(ThreadSpecific<Vector<IDBTransactionBackendInterface*> >*, transactions = new ThreadSpecific<Vector<IDBTransactionBackendInterface*> >);
+ return *transactions;
+}
void IDBPendingTransactionMonitor::addPendingTransaction(IDBTransactionBackendInterface* transaction)
{
- if (!m_transactions)
- m_transactions = new Vector<IDBTransactionBackendInterface*>();
- m_transactions->append(transaction);
+ transactions()->append(transaction);
}
void IDBPendingTransactionMonitor::removePendingTransaction(IDBTransactionBackendInterface* transaction)
{
- if (!m_transactions)
- return;
-
- size_t pos = m_transactions->find(transaction);
+ ThreadSpecific<Vector<IDBTransactionBackendInterface*> >& transactionList = transactions();
+ size_t pos = transactionList->find(transaction);
if (pos == notFound)
return;
- m_transactions->remove(pos);
-
- if (!m_transactions->size()) {
- delete m_transactions;
- m_transactions = 0;
- }
+ transactionList->remove(pos);
}
void IDBPendingTransactionMonitor::abortPendingTransactions()
{
- if (!m_transactions)
- return;
-
- for (size_t i = 0; i < m_transactions->size(); ++i)
- m_transactions->at(i)->abort();
-
- delete m_transactions;
- m_transactions = 0;
+ ThreadSpecific<Vector<IDBTransactionBackendInterface*> >& transactionList = transactions();
+ for (size_t i = 0; i < transactions()->size(); ++i)
+ transactionList->at(i)->abort();
+ // FIXME: Exercise this call to clear() in a layout test.
+ transactionList->clear();
}
};
Modified: trunk/Source/WebCore/storage/IDBPendingTransactionMonitor.h (101625 => 101626)
--- trunk/Source/WebCore/storage/IDBPendingTransactionMonitor.h 2011-12-01 07:47:27 UTC (rev 101625)
+++ trunk/Source/WebCore/storage/IDBPendingTransactionMonitor.h 2011-12-01 07:59:13 UTC (rev 101626)
@@ -40,10 +40,7 @@
// operation is currently queued for it (e.g. an IDBObjectStore::put() or similar).
// All pending transactions are aborted as soon as execution returns from
// the script engine.
-//
-// FIXME: move the vector of transactions to TLS. Keeping it static
-// will not work once we add support for workers. Another possible
-// solution is to keep the vector in the ScriptExecutionContext.
+
class IDBPendingTransactionMonitor {
WTF_MAKE_NONCOPYABLE(IDBPendingTransactionMonitor);
public:
@@ -53,8 +50,6 @@
private:
IDBPendingTransactionMonitor();
-
- static Vector<IDBTransactionBackendInterface*>* m_transactions;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes