ircsocket: don't shutdown on error robbat-debug
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 15 Feb 2011 21:18:52 +0000 (22:18 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 22 Mar 2011 19:27:07 +0000 (20:27 +0100)
commit7598bc6f7529b746f09262c6f0553cce796e2f18
tree8d827d247940ac47d1a32b8a247247a124ce1a66
parent00ff4aee86ba55ce7a813496d245edc43a57623c
ircsocket: don't shutdown on error

Instead, signal the faulty state and re-raise on the next select. This
is to improve the bot behavior if the socket error happens in a separate
thread while the main loop is still processing input.

Such a situation can be given for example during a netsplit. In some
cases (e.g. the bot is on many channels) the processing of the netsplit
events can take a long time, so that the server will disconnect the bot
for ping timeout. While the bot has not realized it has been
disconnected (not got to the :ERROR message from the server yet, and the
socket still has (buffered) data), some action (e.g. an rss update)
causes the bot to try to talk to the server, resulting in a broken pipe.

At this point, with the old code, the socket would be disconnected
without the bot realizing it, causing it to fail to reconnect.
lib/rbot/ircsocket.rb