summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-11-04 14:02:32 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-31 10:10:20 +0000
commitc72d8913b3d64ba445807ac3a858c981fad8d3ea (patch)
tree679063dc8c8cf4ce55638756ee82e046bfd432c6 /bitbake
parente3743bbe945d77e14e2593fc6a1f255f71b96861 (diff)
downloadpoky-c72d8913b3d64ba445807ac3a858c981fad8d3ea.tar.gz
bitbake: prserv/serv: Ensure sync happens in the correct thread
The sync/commit calls are happening in the submission thread which can race against the handler. The handler may start new transactions which then causes the submission thread to error with "cannot start a transaction within a transaction". The fix is to move the calls to the correct thread. (Bitbake rev: 08cf468ab751f4c6e4ffdab2d8e5d748f7698593) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/prserv/serv.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 6ab10972e7..25eb46a410 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -76,11 +76,19 @@ class PRServer(SimpleXMLRPCServer):
76 In addition, exception handling is done here. 76 In addition, exception handling is done here.
77 77
78 """ 78 """
79 iter_count = 1
80 # With 60 iterations between syncs and a 0.5 second timeout between
81 # iterations, this will sync if dirty every ~30 seconds.
82 iterations_between_sync = 60
83
79 while True: 84 while True:
80 (request, client_address) = self.requestqueue.get() 85 (request, client_address) = self.requestqueue.get()
81 try: 86 try:
82 self.finish_request(request, client_address) 87 self.finish_request(request, client_address)
83 self.shutdown_request(request) 88 self.shutdown_request(request)
89 iter_count = (iter_count + 1) % iterations_between_sync
90 if iter_count == 0:
91 self.table.sync_if_dirty()
84 except: 92 except:
85 self.handle_error(request, client_address) 93 self.handle_error(request, client_address)
86 self.shutdown_request(request) 94 self.shutdown_request(request)
@@ -122,10 +130,6 @@ class PRServer(SimpleXMLRPCServer):
122 def work_forever(self,): 130 def work_forever(self,):
123 self.quit = False 131 self.quit = False
124 self.timeout = 0.5 132 self.timeout = 0.5
125 iter_count = 1
126 # With 60 iterations between syncs and a 0.5 second timeout between
127 # iterations, this will sync if dirty every ~30 seconds.
128 iterations_between_sync = 60
129 133
130 logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" % 134 logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" %
131 (self.dbfile, self.host, self.port, str(os.getpid()))) 135 (self.dbfile, self.host, self.port, str(os.getpid())))
@@ -133,9 +137,6 @@ class PRServer(SimpleXMLRPCServer):
133 self.handlerthread.start() 137 self.handlerthread.start()
134 while not self.quit: 138 while not self.quit:
135 self.handle_request() 139 self.handle_request()
136 iter_count = (iter_count + 1) % iterations_between_sync
137 if iter_count == 0:
138 self.table.sync_if_dirty()
139 140
140 self.table.sync() 141 self.table.sync()
141 logger.info("PRServer: stopping...") 142 logger.info("PRServer: stopping...")