summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/prserv/serv.py
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:47:48 +0000
commitbe032fc40eb315841fdd1f69c780726619ea1bad (patch)
tree71c6d9db5485ef8bfcf373dd85f94a9fc17e0274 /bitbake/lib/prserv/serv.py
parent1e95ebd4c3f8364479c371d2c4bc4f643db3262f (diff)
downloadpoky-be032fc40eb315841fdd1f69c780726619ea1bad.tar.gz
bitbake: 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] (Bitbake rev: bc867c81e3894da5bdd2e45fa695bb5f5f1bb58b) Signed-off-by: Diego Santa Cruz <Diego.SantaCruz@spinetix.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv/serv.py')
-rw-r--r--bitbake/lib/prserv/serv.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index a4ae229134..1303f12b45 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -62,9 +62,6 @@ class PRServer(SimpleXMLRPCServer):
62 self.register_function(self.importone, "importone") 62 self.register_function(self.importone, "importone")
63 self.register_introspection_functions() 63 self.register_introspection_functions()
64 64
65 self.db = prserv.db.PRData(self.dbfile)
66 self.table = self.db["PRMAIN"]
67
68 self.requestqueue = Queue.Queue() 65 self.requestqueue = Queue.Queue()
69 self.handlerthread = threading.Thread(target = self.process_request_thread) 66 self.handlerthread = threading.Thread(target = self.process_request_thread)
70 self.handlerthread.daemon = False 67 self.handlerthread.daemon = False
@@ -100,10 +97,12 @@ class PRServer(SimpleXMLRPCServer):
100 self.table.sync_if_dirty() 97 self.table.sync_if_dirty()
101 98
102 def sigint_handler(self, signum, stack): 99 def sigint_handler(self, signum, stack):
103 self.table.sync() 100 if self.table:
101 self.table.sync()
104 102
105 def sigterm_handler(self, signum, stack): 103 def sigterm_handler(self, signum, stack):
106 self.table.sync() 104 if self.table:
105 self.table.sync()
107 raise SystemExit 106 raise SystemExit
108 107
109 def process_request(self, request, client_address): 108 def process_request(self, request, client_address):
@@ -145,6 +144,10 @@ class PRServer(SimpleXMLRPCServer):
145 144
146 bb.utils.set_process_name("PRServ") 145 bb.utils.set_process_name("PRServ")
147 146
147 # DB connection must be created after all forks
148 self.db = prserv.db.PRData(self.dbfile)
149 self.table = self.db["PRMAIN"]
150
148 logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" % 151 logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" %
149 (self.dbfile, self.host, self.port, str(os.getpid()))) 152 (self.dbfile, self.host, self.port, str(os.getpid())))
150 153