From f34e1384f1b6e45edafd722bb918a8c39914f5a9 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 9 Apr 2013 01:24:09 -0400 Subject: [PATCH] use sock.sendall instead of sock.send to fix Ubuntu restart-hang issue --- bitmessagemain.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bitmessagemain.py b/bitmessagemain.py index 6bde803e..f7774396 100755 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -499,7 +499,7 @@ class receiveDataThread(QThread): printLock.acquire() print 'Sending huge inv message with', numberOfObjects, 'objects to just this one peer' printLock.release() - self.sock.send(headerData + payload) + self.sock.sendall(headerData + payload) #We have received a broadcast message def recbroadcast(self,data): @@ -1259,7 +1259,7 @@ class receiveDataThread(QThread): headerData += pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce. headerData += hashlib.sha512(payload).digest()[:4] try: - self.sock.send(headerData + payload) + self.sock.sendall(headerData + payload) except Exception, err: #if not 'Bad file descriptor' in err: printLock.acquire() @@ -1303,28 +1303,28 @@ class receiveDataThread(QThread): headerData += 'pubkey\x00\x00\x00\x00\x00\x00' headerData += pack('>L',len(payload)) #payload length. headerData += hashlib.sha512(payload).digest()[:4] - self.sock.send(headerData + payload) + self.sock.sendall(headerData + payload) elif objectType == 'getpubkey' or objectType == 'pubkeyrequest': print 'sending getpubkey' headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits. headerData += 'getpubkey\x00\x00\x00' headerData += pack('>L',len(payload)) #payload length. headerData += hashlib.sha512(payload).digest()[:4] - self.sock.send(headerData + payload) + self.sock.sendall(headerData + payload) elif objectType == 'msg': print 'sending msg' headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits. headerData += 'msg\x00\x00\x00\x00\x00\x00\x00\x00\x00' headerData += pack('>L',len(payload)) #payload length. headerData += hashlib.sha512(payload).digest()[:4] - self.sock.send(headerData + payload) + self.sock.sendall(headerData + payload) elif objectType == 'broadcast': print 'sending broadcast' headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits. headerData += 'broadcast\x00\x00\x00' headerData += pack('>L',len(payload)) #payload length. headerData += hashlib.sha512(payload).digest()[:4] - self.sock.send(headerData + payload) + self.sock.sendall(headerData + payload) else: sys.stderr.write('Error: sendData has been asked to send a strange objectType: %s\n' % str(objectType)) @@ -1534,7 +1534,7 @@ class receiveDataThread(QThread): printLock.acquire() print 'Sending addr with', numberOfAddressesInAddrMessage, 'entries.' printLock.release() - self.sock.send(datatosend) + self.sock.sendall(datatosend) #We have received a version message def recversion(self,data): @@ -1618,7 +1618,7 @@ class receiveDataThread(QThread): printLock.acquire() print 'Sending version message' printLock.release() - self.sock.send(datatosend) + self.sock.sendall(datatosend) #self.versionSent = 1 #Sends a verack message @@ -1696,7 +1696,7 @@ class sendDataThread(QThread): printLock.acquire() print 'Sending version packet: ', repr(datatosend) printLock.release() - self.sock.send(datatosend) + self.sock.sendall(datatosend) self.versionSent = 1