Przeglądaj źródła

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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Richard Purdie 3 lat temu
rodzic
commit
12605e30e4
2 zmienionych plików z 5 dodań i 3 usunięć
  1. 2 1
      lib/bb/command.py
  2. 3 2
      lib/bb/cooker.py

+ 2 - 1
lib/bb/command.py

@@ -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:
     """

+ 3 - 2
lib/bb/cooker.py

@@ -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