setTimeout may be called as a supybot.drivers.poll callback,
which may by the access to supybot.drivers.poll() in _select;
so a crash in setTimeout will propage up to _run(), which would
cause a random driver to be killed because another one failed
and that's bad.
For example:
INFO 2020-05-27T18:40:18 supybot Received SIGHUP, reloading configuration.
ERROR 2020-05-27T18:40:19 supybot Uncaught exception in in drivers.run:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/supybot/drivers/__init__.py", line 104, in run
driver.run()
File "/usr/lib/python3/dist-packages/supybot/drivers/Socket.py", line 194, in run
self._select()
File "/usr/lib/python3/dist-packages/supybot/drivers/Socket.py", line 167, in _select
[], [], conf.supybot.drivers.poll())
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 422, in __call__
self.set(_cache[self._name])
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 476, in set
self.setValue(float(s))
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 495, in setValue
super(PositiveFloat, self).setValue(v)
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 482, in setValue
super(Float, self).setValue(float(v))
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 385, in setValue
callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/supybot/drivers/Socket.py", line 305, in setTimeout
self.conn.settimeout(conf.supybot.drivers.poll())
OSError: [Errno 9] Bad file descriptor
ERROR 2020-05-27T18:40:19 supybot Exception id: 0x86ecf
INFO 2020-05-27T18:40:21 supybot Removing driver SocketDriver(Irc object for irchaven).
If on an insecure connection: reconnect.
If on a secure connect: store it and do nothing else.
For now, stored STS policies are not read when connecting to an
insecure server.
There's no reason to use it anymore instead of Socket.
It's already missing features compared to Socket, and I don't want to
maintain it anymore so it will keep getting worse.
The connect() method already adds it, so it was in the list twice
(added both by __init__() and connect()).
This caused _select() to call _read() twice on the same instance,
except there is usually nothing to read on the second call,
so it blocks for up to conf.supybot.drivers.poll().
Having it enabled by default would break existing bots just by
doing the update.
Let's just show a warning and give owners some time to update
their config, for the moment.
driver.reconnect(wait=True) should flag a driver to reconnect, but not
immediately. The Socket driver lost its handling of this flag in
8730832e.
Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
Instead of assuming the first address returned from getaddrinfo can be
reached, try each one in turn until a connection is established.
Signed-off-by: James McCoy <jamessan@users.sourceforge.net>