summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2024-05-30 09:42:30 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-05-31 16:56:25 +0100
commitc2d2ae7b1d16c30ca9333a61a2765bdf59dddcba (patch)
tree970d34a0d94effe8159e04ca517846d4f5ba0703 /bitbake
parent5a308474c21a44e22a3cc8e23a9a41269cb51266 (diff)
downloadpoky-c2d2ae7b1d16c30ca9333a61a2765bdf59dddcba.tar.gz
bitbake: hashserv: client: Fix changing stream modes
When switching from normal mode to stream mode, skip calling self._set_mode() again because this will cause a recursion into the _set_mode() function and causes problems. Also cleanup some of the error checking during this process This bug affected when a client would attempt to switch from one stream mode to another, and meant that the server would get an invalid message from the client. This would cause the server to disconnect the client, and the client would then reconnect in normal mode which was the mode it wanted anyway and thus it would carry on without any errors. This made the bug not visible on the client side, but resulting in a lot of backtrace JSON decoding exceptions in the server logs. (Bitbake rev: 1826bc41ab3369ac40034c5eaf698748b769b881) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/hashserv/client.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/bitbake/lib/hashserv/client.py b/bitbake/lib/hashserv/client.py
index d415617b20..a510f3284f 100644
--- a/bitbake/lib/hashserv/client.py
+++ b/bitbake/lib/hashserv/client.py
@@ -121,24 +121,28 @@ class AsyncClient(bb.asyncrpc.AsyncClient):
121 121
122 return await self._send_wrapper(proc) 122 return await self._send_wrapper(proc)
123 123
124 async def invoke(self, *args, **kwargs): 124 async def invoke(self, *args, skip_mode=False, **kwargs):
125 # It's OK if connection errors cause a failure here, because the mode 125 # It's OK if connection errors cause a failure here, because the mode
126 # is also reset to normal on a new connection 126 # is also reset to normal on a new connection
127 await self._set_mode(self.MODE_NORMAL) 127 if not skip_mode:
128 await self._set_mode(self.MODE_NORMAL)
128 return await super().invoke(*args, **kwargs) 129 return await super().invoke(*args, **kwargs)
129 130
130 async def _set_mode(self, new_mode): 131 async def _set_mode(self, new_mode):
131 async def stream_to_normal(): 132 async def stream_to_normal():
133 # Check if already in normal mode (e.g. due to a connection reset)
134 if self.mode == self.MODE_NORMAL:
135 return "ok"
132 await self.socket.send("END") 136 await self.socket.send("END")
133 return await self.socket.recv() 137 return await self.socket.recv()
134 138
135 async def normal_to_stream(command): 139 async def normal_to_stream(command):
136 r = await self.invoke({command: None}) 140 r = await self.invoke({command: None}, skip_mode=True)
137 if r != "ok": 141 if r != "ok":
142 self.check_invoke_error(r)
138 raise ConnectionError( 143 raise ConnectionError(
139 f"Unable to transition to stream mode: Bad response from server {r!r}" 144 f"Unable to transition to stream mode: Bad response from server {r!r}"
140 ) 145 )
141
142 self.logger.debug("Mode is now %s", command) 146 self.logger.debug("Mode is now %s", command)
143 147
144 if new_mode == self.mode: 148 if new_mode == self.mode: