Title: [242983] trunk/Source/WebCore
Revision
242983
Author
[email protected]
Date
2019-03-14 18:54:22 -0700 (Thu, 14 Mar 2019)

Log Message

Web process is put to suspended when holding locked WebSQL files
https://bugs.webkit.org/show_bug.cgi?id=195768

Reviewed by Geoffrey Garen.

We need to keep processes active during database close, because SQLite database may run a checkpoint operation
and lock database files.

* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::useWALJournalMode):
(WebCore::SQLiteDatabase::close):
* platform/sql/SQLiteDatabase.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (242982 => 242983)


--- trunk/Source/WebCore/ChangeLog	2019-03-15 01:28:49 UTC (rev 242982)
+++ trunk/Source/WebCore/ChangeLog	2019-03-15 01:54:22 UTC (rev 242983)
@@ -1,3 +1,18 @@
+2019-03-14  Sihui Liu  <[email protected]>
+
+        Web process is put to suspended when holding locked WebSQL files
+        https://bugs.webkit.org/show_bug.cgi?id=195768
+
+        Reviewed by Geoffrey Garen.
+
+        We need to keep processes active during database close, because SQLite database may run a checkpoint operation
+        and lock database files.
+
+        * platform/sql/SQLiteDatabase.cpp:
+        (WebCore::SQLiteDatabase::useWALJournalMode):
+        (WebCore::SQLiteDatabase::close):
+        * platform/sql/SQLiteDatabase.h:
+
 2019-03-14  Brent Fulgham  <[email protected]>
 
         Move CoreCrypto SPI declarations to an appropriate PAL/spi header

Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp (242982 => 242983)


--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2019-03-15 01:28:49 UTC (rev 242982)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2019-03-15 01:54:22 UTC (rev 242983)
@@ -30,6 +30,7 @@
 #include "DatabaseAuthorizer.h"
 #include "Logging.h"
 #include "MemoryRelease.h"
+#include "SQLiteDatabaseTracker.h"
 #include "SQLiteFileSystem.h"
 #include "SQLiteStatement.h"
 #include <mutex>
@@ -133,6 +134,7 @@
 
 void SQLiteDatabase::useWALJournalMode()
 {
+    m_useWAL = true;
     {
         SQLiteStatement walStatement(*this, "PRAGMA journal_mode=WAL;"_s);
         if (walStatement.prepareAndStep() == SQLITE_ROW) {
@@ -146,6 +148,7 @@
     }
 
     {
+        SQLiteTransactionInProgressAutoCounter transactionCounter;
         SQLiteStatement checkpointStatement(*this, "PRAGMA wal_checkpoint(TRUNCATE)"_s);
         if (checkpointStatement.prepareAndStep() == SQLITE_ROW) {
             if (checkpointStatement.getColumnInt(0))
@@ -165,7 +168,11 @@
             LockHolder locker(m_databaseClosingMutex);
             m_db = 0;
         }
-        sqlite3_close(db);
+        if (m_useWAL) {
+            SQLiteTransactionInProgressAutoCounter transactionCounter;
+            sqlite3_close(db);
+        } else
+            sqlite3_close(db);
     }
 
     m_openingThread = nullptr;

Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.h (242982 => 242983)


--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.h	2019-03-15 01:28:49 UTC (rev 242982)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.h	2019-03-15 01:54:22 UTC (rev 242983)
@@ -155,7 +155,9 @@
 #ifndef NDEBUG
     bool m_sharable { false };
 #endif
-    
+
+    bool m_useWAL { false };
+
     Lock m_authorizerLock;
     RefPtr<DatabaseAuthorizer> m_authorizer;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to