Added delayed death and fixed a bugz0r (die wasn't calling driver.IrcDriver.die)

This commit is contained in:
Jeremy Fincher 2004-08-23 12:09:43 +00:00
parent 992cbb91ee
commit f467550400

View File

@ -62,6 +62,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
self.eagains = 0 self.eagains = 0
self.inbuffer = '' self.inbuffer = ''
self.outbuffer = '' self.outbuffer = ''
self.zombie = False
self.connected = False self.connected = False
self.reconnectWaitsIndex = 0 self.reconnectWaitsIndex = 0
self.reconnectWaits = reconnectWaits self.reconnectWaits = reconnectWaits
@ -78,6 +79,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
self.eagains += 1 self.eagains += 1
def _sendIfMsgs(self): def _sendIfMsgs(self):
if not self.zombie:
msgs = [self.irc.takeMsg()] msgs = [self.irc.takeMsg()]
while msgs[-1] is not None: while msgs[-1] is not None:
msgs.append(self.irc.takeMsg()) msgs.append(self.irc.takeMsg())
@ -90,6 +92,8 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
self.eagains = 0 self.eagains = 0
except socket.error, e: except socket.error, e:
self._handleSocketError(e) self._handleSocketError(e)
if self.zombie and not self.outbuffer:
self._reallyDie()
def run(self): def run(self):
if not self.connected: if not self.connected:
@ -179,9 +183,13 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
schedule.addEvent(self.reconnect, when) schedule.addEvent(self.reconnect, when)
def die(self): def die(self):
self.zombie = True
drivers.log.die(self.irc) drivers.log.die(self.irc)
def _reallyDie(self):
if self.conn is not None: if self.conn is not None:
self.conn.close() self.conn.close()
drivers.IrcDriver.die(self)
# self.irc.die() Kill off the ircs yourself, jerk! # self.irc.die() Kill off the ircs yourself, jerk!
def name(self): def name(self):