mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Updated some logs, fixed a major bug with reconnecting in irc.reset.
This commit is contained in:
parent
8f72aeca1a
commit
d2ff10b25d
@ -152,7 +152,8 @@ class IrcMsgQueue(object):
|
||||
def enqueue(self, msg):
|
||||
"""Enqueues a given message."""
|
||||
if msg in self.msgs:
|
||||
log.warning('Not adding message %r to queue, already added.' % msg)
|
||||
s = str(msg).strip()
|
||||
log.warning('Not adding message %r to queue, already added.', s)
|
||||
else:
|
||||
self.msgs.add(msg)
|
||||
if msg.command in _high:
|
||||
@ -460,12 +461,12 @@ class Irc(IrcCommandDispatcher):
|
||||
def reset(self):
|
||||
"""Resets the Irc object. Called when the driver reconnects."""
|
||||
self._setNonResettingVariables()
|
||||
self._queueConnectMessages()
|
||||
self.state.reset()
|
||||
self.queue.reset()
|
||||
self.fastqueue.reset()
|
||||
for callback in self.callbacks:
|
||||
callback.reset()
|
||||
self._queueConnectMessages()
|
||||
|
||||
def _setNonResettingVariables(self):
|
||||
# Configuration stuff.
|
||||
@ -486,9 +487,9 @@ class Irc(IrcCommandDispatcher):
|
||||
if self.password:
|
||||
log.info('Sending PASS command, not logging the password.')
|
||||
self.queueMsg(ircmsgs.password(self.password))
|
||||
log.info('Sending NICK command, nick is %s.', self.nick)
|
||||
log.info('Queueing NICK command, nick is %s.', self.nick)
|
||||
self.queueMsg(ircmsgs.nick(self.nick))
|
||||
log.info('Sending USER command, ident is %s, user is %s.',
|
||||
log.info('Queueing USER command, ident is %s, user is %s.',
|
||||
self.ident, self.user)
|
||||
self.queueMsg(ircmsgs.user(self.ident, self.user))
|
||||
|
||||
|
@ -92,7 +92,8 @@ class SocketDriver(drivers.IrcDriver):
|
||||
# (11, 'Resource temporarily unavailable') raised if connect
|
||||
# hasn't finished yet.
|
||||
if e.args[0] != 11 and self.eagains > 120:
|
||||
log.warning('Disconnect from %s: %s', self.server, e)
|
||||
server = '%s:%s' % self.server
|
||||
log.warning('Disconnect from %s: %s', server, e.args[1])
|
||||
self.reconnect(wait=True)
|
||||
else:
|
||||
log.debug('Got EAGAIN, current count: %s', self.eagains)
|
||||
@ -128,26 +129,31 @@ class SocketDriver(drivers.IrcDriver):
|
||||
return
|
||||
self._sendIfMsgs()
|
||||
|
||||
def connect(self, wait=False):
|
||||
self.reconnect(wait, reset=False)
|
||||
def connect(self, **kwargs):
|
||||
self.reconnect(reset=False, **kwargs)
|
||||
|
||||
def reconnect(self, wait=False, reset=True):
|
||||
server = '%s:%s' % self.server
|
||||
self.irc.reset()
|
||||
if self.connected:
|
||||
log.info('Reconnect called on driver for %s.' % self.irc)
|
||||
log.info('Reconnect called on driver for %s.', self.irc)
|
||||
self.conn.close()
|
||||
elif not wait:
|
||||
log.info('Connecting to %s.' % ':'.join(map(str, self.server)))
|
||||
log.info('Connecting to %s.', server)
|
||||
self.connected = False
|
||||
if wait:
|
||||
log.info('Reconnect waiting.')
|
||||
log.info('Reconnect to %s waiting.', server)
|
||||
self._scheduleReconnect()
|
||||
return
|
||||
if reset:
|
||||
log.debug('Resetting %s.', self.irc)
|
||||
self.irc.reset()
|
||||
else:
|
||||
log.debug('Not resetting %s.', self.irc)
|
||||
try:
|
||||
self.conn = utils.getSocket(self.server[0])
|
||||
except socket.error, e:
|
||||
log.warning('Error connecting to %s: %s', self.server[0], e)
|
||||
log.warning('Error connecting to %s: %s', server, e.args[1])
|
||||
self.reconnect(wait=True)
|
||||
return
|
||||
# We allow more time for the connect here, since it might take longer.
|
||||
@ -188,7 +194,8 @@ class SocketDriver(drivers.IrcDriver):
|
||||
when = time.time() + self.reconnectWaits[self.reconnectWaitsIndex]
|
||||
if not world.dying:
|
||||
whenS = log.timestamp(when)
|
||||
log.info('Scheduling reconnect to %s at %s', self.server, whenS)
|
||||
server = '%s:%s' % self.server
|
||||
log.info('Scheduling reconnect to %s at %s', server, whenS)
|
||||
schedule.addEvent(self.reconnect, when)
|
||||
|
||||
def die(self):
|
||||
|
Loading…
Reference in New Issue
Block a user