Bug 1469054 - Make sure that the adb.py sends all data. r?jdescottes
It seems that, on chaos mode, we can't receive whole data set at once, i.e.
sending data will be split into some chunks, so the adb mock should check the
sent data length and if there remains still data which has to be sent, we have
to continue sending the rest of the data.
MozReview-Commit-ID: 5jeEH8KpNNW
--- a/devtools/shared/adb/test/adb.py
+++ b/devtools/shared/adb/test/adb.py
@@ -15,19 +15,27 @@ import SocketServer
import sys
import thread
HOST = '127.0.0.1'
PORT = 5037
class ADBServer(SocketServer.BaseRequestHandler):
def sendData(self, data):
- self.request.send('OKAY')
- self.request.send('%04x' % len(data))
- self.request.send(data)
+ header = 'OKAY%04x' % len(data)
+ all_data = header + data
+ total_length = len(all_data)
+ sent_length = 0
+ # Make sure send all data to the client.
+ # Though the data length here is pretty small but sometimes when the
+ # client is on heavy load (e.g. MOZ_CHAOSMODE) we can't send the whole
+ # data at once.
+ while sent_length < total_length:
+ sent = self.request.send(all_data[sent_length:])
+ sent_length = sent_length + sent
def handle(self):
while True:
data = self.request.recv(4096)
if 'kill-server' in data:
def shutdown(server):
server.shutdown()
thread.exit()