瀏覽代碼

set PeerConnection._sent_uuid in constructor, to avoid race conditions

Malte Kraus 8 年之前
父節點
當前提交
e791187f0a
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/protocol.py

+ 1 - 1
src/protocol.py

@@ -41,6 +41,7 @@ class PeerConnection:
         self.socket = sock
         self.proto = proto
         self.is_connected = False
+        self._sent_uuid = str(uuid4())
         self.outgoing_msgs = Queue()
 
         Thread(target=self.run, daemon=True).start()
@@ -68,7 +69,6 @@ class PeerConnection:
 
         self.send_msg("myport", self.proto.server.server_address[1])
         self.send_msg("block", self.proto._primary_block)
-        self._sent_uuid = str(uuid4())
         self.send_msg("id", self._sent_uuid)
         self.send_peers()