##// END OF EJS Templates
zeroconf: do not crash if socket being read is closed by another thread...
Jun Wu -
r34448:5385b76f default
parent child Browse files
Show More
@@ -80,6 +80,7 b' from __future__ import absolute_import, '
80 __email__ = "paul at scott dash murphy dot com"
80 __email__ = "paul at scott dash murphy dot com"
81 __version__ = "0.12"
81 __version__ = "0.12"
82
82
83 import errno
83 import itertools
84 import itertools
84 import select
85 import select
85 import socket
86 import socket
@@ -937,7 +938,16 b' class Listener(object):'
937 self.zeroconf.engine.addReader(self, self.zeroconf.socket)
938 self.zeroconf.engine.addReader(self, self.zeroconf.socket)
938
939
939 def handle_read(self):
940 def handle_read(self):
940 data, (addr, port) = self.zeroconf.socket.recvfrom(_MAX_MSG_ABSOLUTE)
941 data = addr = port = None
942 sock = self.zeroconf.socket
943 try:
944 data, (addr, port) = sock.recvfrom(_MAX_MSG_ABSOLUTE)
945 except socket.error as e:
946 if e.errno == errno.EBADF:
947 # some other thread may close the socket
948 return
949 else:
950 raise
941 self.data = data
951 self.data = data
942 msg = DNSIncoming(data)
952 msg = DNSIncoming(data)
943 if msg.isQuery():
953 if msg.isQuery():
General Comments 0
You need to be logged in to leave comments. Login now