--- gvpe/src/connection.C 2011/03/24 21:52:48 1.96 +++ gvpe/src/connection.C 2012/12/04 13:23:17 1.97 @@ -694,6 +694,7 @@ // make sure rekeying timeouts are slightly asymmetric ev::tstamp rekey_interval = ::conf.rekey + (conf->id > THISNODE->id ? 10 : 0); rekey.start (rekey_interval, rekey_interval); + keepalive.start (::conf.keepalive); // send queued packets @@ -1347,23 +1348,25 @@ inline void connection::keepalive_cb (ev::timer &w, int revents) { - if (ev_now () >= last_activity + ::conf.keepalive + 15) + ev_tstamp when = last_activity + ::conf.keepalive - ev::now (); + + if (when >= 0) + w.start (when); + else if (when < -15) { reset_connection (); establish_connection (); } - else if (ev_now () < last_activity + ::conf.keepalive) - w.start (last_activity + ::conf.keepalive - ev::now ()); else if (conf->connectmode != conf_node::C_ONDEMAND || THISNODE->connectmode != conf_node::C_ONDEMAND) { - send_ping (si); w.start (3); + send_ping (si); } - else if (ev_now () < last_activity + ::conf.keepalive + 10) + else if (when >= -10) // hold ondemand connections implicitly a few seconds longer // should delete octx, though, or something like that ;) - w.start (last_activity + ::conf.keepalive + 10 - ev::now ()); + w.start (when + 10); else reset_connection (); }