1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix for network byte order issues in accelerate

This commit is contained in:
James Cammarata 2013-10-02 15:36:37 -05:00
parent df529b9b69
commit d21714a37f
2 changed files with 4 additions and 4 deletions

View file

@ -129,7 +129,7 @@ class Connection(object):
return self return self
def send_data(self, data): def send_data(self, data):
packed_len = struct.pack('Q',len(data)) packed_len = struct.pack('!Q',len(data))
return self.conn.sendall(packed_len + data) return self.conn.sendall(packed_len + data)
def recv_data(self): def recv_data(self):
@ -144,7 +144,7 @@ class Connection(object):
return None return None
data += d data += d
vvvv("%s: got the header, unpacking" % self.host) vvvv("%s: got the header, unpacking" % self.host)
data_len = struct.unpack('Q',data[:header_len])[0] data_len = struct.unpack('!Q',data[:header_len])[0]
data = data[header_len:] data = data[header_len:]
vvvv("%s: data received so far (expecting %d): %d" % (self.host,data_len,len(data))) vvvv("%s: data received so far (expecting %d): %d" % (self.host,data_len,len(data)))
while len(data) < data_len: while len(data) < data_len:

View file

@ -190,7 +190,7 @@ class ThreadedTCPServer(SocketServer.ThreadingTCPServer):
class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
def send_data(self, data): def send_data(self, data):
packed_len = struct.pack('Q', len(data)) packed_len = struct.pack('!Q', len(data))
return self.request.sendall(packed_len + data) return self.request.sendall(packed_len + data)
def recv_data(self): def recv_data(self):
@ -204,7 +204,7 @@ class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
return None return None
data += d data += d
vvvv("in recv_data(), got the header, unpacking") vvvv("in recv_data(), got the header, unpacking")
data_len = struct.unpack('Q',data[:header_len])[0] data_len = struct.unpack('!Q',data[:header_len])[0]
data = data[header_len:] data = data[header_len:]
vvvv("data received so far (expecting %d): %d" % (data_len,len(data))) vvvv("data received so far (expecting %d): %d" % (data_len,len(data)))
while len(data) < data_len: while len(data) < data_len: