From ddf347ecc56d0658a8413a2cee25a22917301926 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Mon, 29 Apr 2013 14:12:15 -0400 Subject: [PATCH] test socket.close change --- src/bitmessagemain.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 63237e42..7dbeefee 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -284,11 +284,11 @@ class receiveDataThread(QThread): - try: + """try: #self.sock.shutdown(socket.SHUT_RDWR) self.sock.close() except Exception, err: - print 'Within receiveDataThread run(), self.sock.shutdown or .close() failed.', err + print 'Within receiveDataThread run(), self.sock.shutdown or .close() failed.', err""" try: del selfInitiatedConnections[self.streamNumber][self] @@ -452,8 +452,9 @@ class receiveDataThread(QThread): printLock.acquire() print 'We are connected to too many people. Closing connection.' printLock.release() - self.sock.shutdown(socket.SHUT_RDWR) - self.sock.close() + #self.sock.shutdown(socket.SHUT_RDWR) + #self.sock.close() + broadcastToSendDataQueues((0, 'shutdown', self.HOST)) return self.sendBigInv() @@ -1917,8 +1918,9 @@ class receiveDataThread(QThread): print 'Remote node useragent:', useragent, ' stream number:', self.streamNumber printLock.release() if self.streamNumber != 1: - self.sock.shutdown(socket.SHUT_RDWR) - self.sock.close() + #self.sock.shutdown(socket.SHUT_RDWR) + #self.sock.close() + broadcastToSendDataQueues((0, 'shutdown', self.HOST)) printLock.acquire() print 'Closed connection to', self.HOST, 'because they are interested in stream', self.streamNumber,'.' printLock.release() @@ -1927,8 +1929,9 @@ class receiveDataThread(QThread): if not self.initiatedConnection: broadcastToSendDataQueues((0,'setStreamNumber',(self.HOST,self.streamNumber))) if data[72:80] == eightBytesOfRandomDataUsedToDetectConnectionsToSelf: - self.sock.shutdown(socket.SHUT_RDWR) - self.sock.close() + #self.sock.shutdown(socket.SHUT_RDWR) + #self.sock.close() + broadcastToSendDataQueues((0, 'shutdown', self.HOST)) printLock.acquire() print 'Closing connection to myself: ', self.HOST printLock.release() @@ -2020,7 +2023,6 @@ class sendDataThread(QThread): printLock.release() self.sock.shutdown(socket.SHUT_RDWR) self.sock.close() - print 'sendDataThread closed socket.' sendDataQueues.remove(self.mailbox) printLock.acquire() print 'len of sendDataQueues', len(sendDataQueues)