Skip to content

Commit

Permalink
Bug 1207273 - Verify MarionetteTransport.send() sends all data, r=jgr…
Browse files Browse the repository at this point in the history
…iffin
  • Loading branch information
shivin101 committed Jan 11, 2016
1 parent 7165b3e commit 130990b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions testing/marionette/transport/marionette_transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,21 @@ def send(self, obj):
data = json.dumps(obj)
payload = "%s:%s" % (len(data), data)

for packet in [payload[i:i + self.max_packet_length] for i in
range(0, len(payload), self.max_packet_length)]:
totalsent = 0
while totalsent < len(payload):
try:
self.sock.send(packet)
sent = self.sock.send(payload[totalsent:])
if sent == 0:
raise IOError("socket error after sending %d of %d bytes" % \
(totalsent, len(payload)))
else:
totalsent += sent

except IOError as e:
if e.errno == errno.EPIPE:
raise IOError("%s: %s" % (str(e), self.connection_lost_msg))
else:
raise e

def respond(self, obj):
"""Send a response to a command. This can be an arbitrary JSON
serialisable object or an ``Exception``.
Expand Down

0 comments on commit 130990b

Please sign in to comment.