aboutsummaryrefslogtreecommitdiffstats
path: root/lib/prserv
diff options
context:
space:
mode:
authorDiego Santa Cruz <Diego.SantaCruz@spinetix.com>2016-02-02 13:04:20 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-04 23:46:01 +0000
commitbc867c81e3894da5bdd2e45fa695bb5f5f1bb58b (patch)
tree7e9e1f34e7f6fb1e075de63a2c7a95b6fa4ac274 /lib/prserv
parent14c9593265f7469cb8a205a46f845ac7491246df (diff)
downloadbitbake-bc867c81e3894da5bdd2e45fa695bb5f5f1bb58b.tar.gz
bitbake: prserv: -wal and -shm sqlite lost when daemonizing
When daemonizing the PR service the -wal and -shm sqlite files were being deleted, although they should never be. While the daemonized process keeps the file descriptors open and thus a clean exit does not loose any data, a power outage would loose all data in the WAL. Removing these files also breaks sqlite collaboration between processes and furthermore prevents taking proper backups without stopping the PR service. The reason this happens is that the DB connection is opened in the initial process, before forking for daemonization. When the DB connection is closed by the exiting parent processes it can delete the -wal and -shm files if it considers itself to be the last connection to the DB. This is easily fixed by opening the DB connection after all forking. [YOCTO #9034] Signed-off-by: Diego Santa Cruz <Diego.SantaCruz@spinetix.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/prserv')
-rw-r--r--lib/prserv/serv.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
index a4ae22913..1303f12b4 100644
--- a/lib/prserv/serv.py
+++ b/lib/prserv/serv.py
@@ -62,9 +62,6 @@ class PRServer(SimpleXMLRPCServer):
self.register_function(self.importone, "importone")
self.register_introspection_functions()
- self.db = prserv.db.PRData(self.dbfile)
- self.table = self.db["PRMAIN"]
-
self.requestqueue = Queue.Queue()
self.handlerthread = threading.Thread(target = self.process_request_thread)
self.handlerthread.daemon = False
@@ -100,10 +97,12 @@ class PRServer(SimpleXMLRPCServer):
self.table.sync_if_dirty()
def sigint_handler(self, signum, stack):
- self.table.sync()
+ if self.table:
+ self.table.sync()
def sigterm_handler(self, signum, stack):
- self.table.sync()
+ if self.table:
+ self.table.sync()
raise SystemExit
def process_request(self, request, client_address):
@@ -145,6 +144,10 @@ class PRServer(SimpleXMLRPCServer):
bb.utils.set_process_name("PRServ")
+ # DB connection must be created after all forks
+ self.db = prserv.db.PRData(self.dbfile)
+ self.table = self.db["PRMAIN"]
+
logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" %
(self.dbfile, self.host, self.port, str(os.getpid())))