[epiphany/gnome-3-22] Fix theoretical race condition in ephy_history_service_add_visit_row
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-22] Fix theoretical race condition in ephy_history_service_add_visit_row
- Date: Tue, 21 Feb 2017 02:31:22 +0000 (UTC)
commit c636bdc739c55bb3cb9ddf4915d4137f319dbf86
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Feb 20 20:24:03 2017 -0600
Fix theoretical race condition in ephy_history_service_add_visit_row
The design of the history service feels like one big footgun. I'm really
not sure why a history thread is necessary at all, or why we have
longstanding transactions (defeating the entire purpose of transactions)
instead of just using autocommit, which I think would be sufficient for
everything we do.
This commit doesn't fix any of that. That's just a rant. This commit
just fixes one theoretical race condition. Prepared statements lock the
database and need to be finalized BEFORE commit. The current code only
works if the prepared statement is finalized on the UI thread before the
scheduled commit occurs on the history thread. Which is probably always,
but let's not leave it to luck.
I could see this leading to a small loss of the last bit of history when
closing the browser.
https://bugzilla.gnome.org/show_bug.cgi?id=778649
lib/history/ephy-history-service-visits-table.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/lib/history/ephy-history-service-visits-table.c b/lib/history/ephy-history-service-visits-table.c
index 75c052b..855d6c2 100644
--- a/lib/history/ephy-history-service-visits-table.c
+++ b/lib/history/ephy-history-service-visits-table.c
@@ -81,8 +81,12 @@ ephy_history_service_add_visit_row (EphyHistoryService *self, EphyHistoryPageVis
visit->id = ephy_sqlite_connection_get_last_insert_id (self->history_database);
}
- ephy_history_service_schedule_commit (self);
+ /* Remember kids: prepared statements lock the database! They must be unreffed
+ * before scheduling commit.
+ */
g_object_unref (statement);
+
+ ephy_history_service_schedule_commit (self);
}
static EphyHistoryPageVisit *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]