Socket: Fix race condition in SSL handshakes.

This commit is contained in:
Valentin Lorentz 2013-03-21 17:21:20 +00:00
parent 881eb9f771
commit cac96aa5f7

View File

@ -278,14 +278,14 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
# At least 10 seconds. # At least 10 seconds.
self.conn.settimeout(max(10, conf.supybot.drivers.poll()*10)) self.conn.settimeout(max(10, conf.supybot.drivers.poll()*10))
try: try:
if getattr(conf.supybot.networks, self.irc.network).ssl():
assert globals().has_key('ssl')
self.conn = ssl.wrap_socket(self.conn)
self.conn.connect(server) self.conn.connect(server)
def setTimeout(): def setTimeout():
self.conn.settimeout(conf.supybot.drivers.poll()) self.conn.settimeout(conf.supybot.drivers.poll())
conf.supybot.drivers.poll.addCallback(setTimeout) conf.supybot.drivers.poll.addCallback(setTimeout)
setTimeout() setTimeout()
if getattr(conf.supybot.networks, self.irc.network).ssl():
assert globals().has_key('ssl')
self.conn = ssl.wrap_socket(self.conn)
self.connected = True self.connected = True
self.resetDelay() self.resetDelay()
except socket.error, e: except socket.error, e: