[Secure-testing-commits] r16645 - / bin lib/python

Florian Weimer fw at alioth.debian.org
Sat May 7 12:56:12 UTC 2011


Author: fw
Date: 2011-05-07 12:56:12 +0000 (Sat, 07 May 2011)
New Revision: 16645

Modified:
   Makefile
   bin/tracker_service.py
   lib/python/security_db.py
Log:
security_db.DB: enable SQLite WAL mode

This means that we no longer have to copy the database file.


Modified: Makefile
===================================================================
--- Makefile	2011-05-07 11:52:37 UTC (rev 16644)
+++ Makefile	2011-05-07 12:56:12 UTC (rev 16645)
@@ -16,10 +16,7 @@
 TESTING   = wheezy
 
 all:
-	rm -f data/security-new.db data/security-new.db.journal
-	if test -e data/security.db; then cp data/security.db data/security-new.db; fi
-	$(PYTHON) bin/update-db data/security-new.db
-	mv data/security-new.db data/security.db
+	$(PYTHON) bin/update-db data/security.db
 
 clean:
 	-rm -f data/security.db lib/python/test_security.db

Modified: bin/tracker_service.py
===================================================================
--- bin/tracker_service.py	2011-05-07 11:52:37 UTC (rev 16644)
+++ bin/tracker_service.py	2011-05-07 12:56:12 UTC (rev 16645)
@@ -1280,6 +1280,6 @@
         return SPAN(contents, _class="dangerous")
 
     def pre_dispatch(self):
-        self.db.refresh()
+        pass
 
 TrackerService(socket_name, db_name).run()

Modified: lib/python/security_db.py
===================================================================
--- lib/python/security_db.py	2011-05-07 11:52:37 UTC (rev 16644)
+++ lib/python/security_db.py	2011-05-07 12:56:12 UTC (rev 16645)
@@ -113,11 +113,19 @@
         self.name = name
         self.db = apsw.Connection(name)
         self.verbose = verbose
+        c = self.cursor()
 
+        # This gives us better performance (it's usually the file
+        # system block size).  This must come first to be effective.
+
+        c.execute("PRAGMA page_size = 4096")
+
+        # Enable WAL.  This means that updates will not block readers.
+        c.execute("PRAGMA journal_mode = WAL")
+
         self.schema_version = 22
         self._initFunctions()
 
-        c = self.cursor()
         for (v,) in c.execute("PRAGMA user_version"):
             if v == 0:
                 self.initSchema()
@@ -138,27 +146,12 @@
                           % (self.schema_version, v)
                 raise SchemaMismatch, `v`
             self._initViews(c)
-            # Database has been created at this point.  Small race
-            # condition here (the already opened database might refer
-            # to an older file).
-            self.__stat = os.stat(self.name)
             return
         assert False
 
     def __del__(self):
         self.db.close()
 
-    def refresh(self):
-        """Checks if the database file is still the same and reopens
-        it if necessary."""
-        current = os.stat(self.name)
-        if os.path.samestat(self.__stat, current):
-            return
-        self.__stat = current
-        self.db = apsw.Connection(self.name)
-        self._initFunctions()
-        self._initViews(self.cursor())
-
     def cursor(self):
         """Creates a new database cursor.
 
@@ -188,11 +181,6 @@
         """Creates the database schema."""
         cursor = self.cursor()
 
-        # This gives us better performance (it's usually the file
-        # system block size).  This must come first to be ffective.
-
-        cursor.execute("PRAGMA page_size = 4096")
-
         # Set the schema version to an invalid value which is
         # different from zero.  We can use this to detect a partially
         # created schema.




More information about the Secure-testing-commits mailing list