Skip to contentSkip to conversation

cooker/command: Fix disconnection handling

PATCH New Richard Purdie 1 participant 1 message Sep 12, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cooker/command: Fix disconnection handling

After the recent init changes, if a client disconnects before issuing a command, the cooker can break in the reset handlers. Add some guards in the code to prevent this.

---
 lib/bb/command.py | 3 ++-
 lib/bb/cooker.py  | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)
lib/bb/command.py +2 -1
index d4dcc653a0..f8c6a03bb9 100644
@@ -143,7 +143,8 @@ class Command:
         self.cooker.finishcommand()
 
     def reset(self):
-        self.remotedatastores = bb.remotedata.RemoteDatastores(self.cooker)
+        if self.remotedatastores:
+           self.remotedatastores = bb.remotedata.RemoteDatastores(self.cooker)
 
 class CommandsSync:
     """
lib/bb/cooker.py +3 -2
index e45755206e..58c223c1ca 100644
@@ -1703,8 +1703,9 @@ class BBCooker:
         self.finishcommand()
         self.extraconfigdata = {}
         self.command.reset()
-        self.databuilder.reset()
-        self.data = self.databuilder.data
+        if hasattr(self, "data"):
+           self.databuilder.reset()
+           self.data = self.databuilder.data
         self.parsecache_valid = False
         self.baseconfig_valid = False
 
Signature · 1 line
2.25.1