This code appears to be some kind of backstop so that the client will notice
a server connection that's died because of a network interruption. Checking
errno that was last set christ-knows-where is not the right way to do this,
though.
The normal write to the server for the lag check should eventually see the
host/net unreachable error if this happens.
Previously the server lag check was run by update_clock() if the number of
seconds since client startup was a multiple of 20 (unless it had already been
done this second). This meant that if update_clock() was not being called
frequently (eg. if your IRC connection was very quiet), it might go a long
time between lag checks.
This commit adds a /set LAG_CHECK_INTERVAL (defaulting to 30). For each
server, a lag check ping is scheduled for every LAG_CHECK_INTERVAL seconds
after the connection is finalised/registered. Setting this value to 0
disables the lag check pings entirely.
The old code set the lag to 'unknown' immediately after sending out a ping,
which meant that it was quite unpredictable how long the lag value would
stay around for. The new code only sets this once the current lag value
has become stale (ie. a ping reply is overdue based on the current lag
value). If your lag is staying the same or reducing, you shouldn't see
the [Lag ??] at all.
An absolute wake time is now calculated and updated by set_server_bits(),
TimerTimeout() and tclTimerTimeout(). This is then used to calculate the actual
select() timeout, instead of having those functions calculate a relative timeout
value themselves. This significantly simplifies those functions, since the
underlying values tend to be recorded as absolute times.
It also allows us to disentangle tclTimeTimeout from TimerTimeout(), and move the
responsibility for calculating the QUEUE_SENDS wake time from TimerTimeout() to
set_server_bits() where it belongs.
The QUEUE_SENDS and CONNECT_DELAY wake up times will also now be correctly
calculated, based on the last sent time and connect time respectively.
This means that settings like CONNECT_DELAY and CONNECT_TIMEOUT are compared
against the current time with sub-second resolution. With the old way, the
delays could be up to a second longer than asked for, which had the effect of
almost doubling the default CONNECT_DELAY value of 1.
set_server_bits() now returns -1 for "no timeout", so 0 is a legitimate
return value.
io() should only update real_timeout from server_timeout if server_timeout
is not -1 (real_timeout == -1 ends up meaning "wait indefinitely").
Note that if you set CONNECT_DELAY to zero you get a lag check ping sent off
first thing in the server connection, this should be fixed.
We now send PING <server> :<server> for /spings, and
PING LAG!<cookie>.<tv_sec>.<tv_usec> :<server> for lag checks. The cookie is
set randomly at server connect time, and means that clients connected to the
same bouncer shouldn't act on each other's lag checks.
We can now remove in_sping entirely - previously it would get out of synch if
you disconnected with a sping in progress.
An snprintf() call that creates IRC protocol messages must use
(MAX_PROTOCOL_SIZE + 1) as 'n' rather than the buffer size.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@461 13b04d17-f746-0410-82c6-800466cd88b0
This includes all of the underlying support, but doesn't hook it up to the
/SERVER command yet, so it's not useable at this point.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@216 13b04d17-f746-0410-82c6-800466cd88b0
huge amount of work on each keystroke if you have a long server list and
start it up disconnected (-N).
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@150 13b04d17-f746-0410-82c6-800466cd88b0
on a socket.
I also added a wrapper function around strerror() for dgets_errno, since
we did the same thing in a few places. This all needs to be cleaned up
a little - the -1 value we use could in theory clash with an actual
errno error number.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@104 13b04d17-f746-0410-82c6-800466cd88b0
per-server, and apply new version of do_oops from flewid (the BX2 version).
This means that /oops, "/query .", "/query ,", "/msg ." and "/msg ," are now
per-server, along with the $. $, and $B aliases.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@87 13b04d17-f746-0410-82c6-800466cd88b0