summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2011-02-11 13:04:18 (GMT)
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2011-02-11 13:04:18 (GMT)
commit42e0b7f47ef3bd1fe3b20ae253c9f660092d2fa4 (patch)
tree85b0f6fa1367f3174eb7dee6635be83da93fd286 /Lib
parent2933312fe71f15d127009c872cd1e5f98a993999 (diff)
downloadcpython-42e0b7f47ef3bd1fe3b20ae253c9f660092d2fa4.zip
cpython-42e0b7f47ef3bd1fe3b20ae253c9f660092d2fa4.tar.gz
cpython-42e0b7f47ef3bd1fe3b20ae253c9f660092d2fa4.tar.bz2
asyncore: introduce a new 'closed' attribute to make sure that dispatcher gets closed only once.
In different occasions close() might be called more than once, causing problems with already disconnected sockets/dispatchers.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncore.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index f0712e2..91c629b 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -220,7 +220,7 @@ class dispatcher:
connected = False
accepting = False
- closing = False
+ closed = False
addr = None
ignore_log_types = frozenset(['warning'])
@@ -393,14 +393,16 @@ class dispatcher:
raise
def close(self):
- self.connected = False
- self.accepting = False
- self.del_channel()
- try:
- self.socket.close()
- except socket.error as why:
- if why.args[0] not in (ENOTCONN, EBADF):
- raise
+ if not self.closed:
+ self.closed = True
+ self.connected = False
+ self.accepting = False
+ self.del_channel()
+ try:
+ self.socket.close()
+ except socket.error as why:
+ if why.args[0] not in (ENOTCONN, EBADF):
+ raise
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.