summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-13 23:32:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-16 00:04:38 +0100
commit43b392536da5890eba097048f882bdea7f3d143a (patch)
treec0fd17fd77321f6565b9ee5360237dea7d66abe6
parent188feb233ab3549af46cf530c0ac31f0a66ac074 (diff)
downloadpoky-43b392536da5890eba097048f882bdea7f3d143a.tar.gz
bitbake: process: Improve client disconnects
There have been cases where the server could loop indefinitely and incorrectly handle client disconnects. In the EOFError case, ensure a full disconnect happens in the alternative disconnect path to avoid this. (Bitbake rev: 5e267f14bb0155889615f567a920af4a37eb3c6b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/server/process.py38
1 files changed, 23 insertions, 15 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index ee8b14ea7d..a7a6fbff69 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -134,6 +134,26 @@ class ProcessServer(multiprocessing.Process):
134 if self.xmlrpc: 134 if self.xmlrpc:
135 fds.append(self.xmlrpc) 135 fds.append(self.xmlrpc)
136 print("Entering server connection loop") 136 print("Entering server connection loop")
137
138 def disconnect_client(self, fds):
139 if not self.haveui:
140 return
141 print("Disconnecting Client")
142 fds.remove(self.controllersock)
143 fds.remove(self.command_channel)
144 bb.event.unregister_UIHhandler(self.event_handle, True)
145 self.command_channel_reply.writer.close()
146 self.event_writer.writer.close()
147 del self.event_writer
148 self.controllersock.close()
149 self.controllersock = False
150 self.haveui = False
151 self.lastui = time.time()
152 self.cooker.clientComplete()
153 if self.timeout is None:
154 print("No timeout, exiting.")
155 self.quit = True
156
137 while not self.quit: 157 while not self.quit:
138 if self.sock in ready: 158 if self.sock in ready:
139 self.controllersock, address = self.sock.accept() 159 self.controllersock, address = self.sock.accept()
@@ -165,21 +185,8 @@ class ProcessServer(multiprocessing.Process):
165 self.haveui = True 185 self.haveui = True
166 186
167 except (EOFError, OSError): 187 except (EOFError, OSError):
168 print("Disconnecting Client") 188 disconnect_client(self, fds)
169 fds.remove(self.controllersock) 189
170 fds.remove(self.command_channel)
171 bb.event.unregister_UIHhandler(self.event_handle, True)
172 self.command_channel_reply.writer.close()
173 self.event_writer.writer.close()
174 del self.event_writer
175 self.controllersock.close()
176 self.controllersock = False
177 self.haveui = False
178 self.lastui = time.time()
179 self.cooker.clientComplete()
180 if self.timeout is None:
181 print("No timeout, exiting.")
182 self.quit = True
183 if not self.timeout == -1.0 and not self.haveui and self.lastui and self.timeout and \ 190 if not self.timeout == -1.0 and not self.haveui and self.lastui and self.timeout and \
184 (self.lastui + self.timeout) < time.time(): 191 (self.lastui + self.timeout) < time.time():
185 print("Server timeout, exiting.") 192 print("Server timeout, exiting.")
@@ -191,6 +198,7 @@ class ProcessServer(multiprocessing.Process):
191 except EOFError: 198 except EOFError:
192 # Client connection shutting down 199 # Client connection shutting down
193 ready = [] 200 ready = []
201 disconnect_client(self, fds)
194 continue 202 continue
195 if command[0] == "terminateServer": 203 if command[0] == "terminateServer":
196 self.quit = True 204 self.quit = True