ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/connection.C
(Generate patch)

Comparing gvpe/src/connection.C (file contents):
Revision 1.96 by root, Thu Mar 24 21:52:48 2011 UTC vs.
Revision 1.97 by root, Tue Dec 4 13:23:17 2012 UTC

692 if (ictx && octx) 692 if (ictx && octx)
693 { 693 {
694 // make sure rekeying timeouts are slightly asymmetric 694 // make sure rekeying timeouts are slightly asymmetric
695 ev::tstamp rekey_interval = ::conf.rekey + (conf->id > THISNODE->id ? 10 : 0); 695 ev::tstamp rekey_interval = ::conf.rekey + (conf->id > THISNODE->id ? 10 : 0);
696 rekey.start (rekey_interval, rekey_interval); 696 rekey.start (rekey_interval, rekey_interval);
697
697 keepalive.start (::conf.keepalive); 698 keepalive.start (::conf.keepalive);
698 699
699 // send queued packets 700 // send queued packets
700 if (ictx && octx) 701 if (ictx && octx)
701 { 702 {
1345} 1346}
1346 1347
1347inline void 1348inline void
1348connection::keepalive_cb (ev::timer &w, int revents) 1349connection::keepalive_cb (ev::timer &w, int revents)
1349{ 1350{
1350 if (ev_now () >= last_activity + ::conf.keepalive + 15) 1351 ev_tstamp when = last_activity + ::conf.keepalive - ev::now ();
1352
1353 if (when >= 0)
1354 w.start (when);
1355 else if (when < -15)
1351 { 1356 {
1352 reset_connection (); 1357 reset_connection ();
1353 establish_connection (); 1358 establish_connection ();
1354 } 1359 }
1355 else if (ev_now () < last_activity + ::conf.keepalive)
1356 w.start (last_activity + ::conf.keepalive - ev::now ());
1357 else if (conf->connectmode != conf_node::C_ONDEMAND 1360 else if (conf->connectmode != conf_node::C_ONDEMAND
1358 || THISNODE->connectmode != conf_node::C_ONDEMAND) 1361 || THISNODE->connectmode != conf_node::C_ONDEMAND)
1359 { 1362 {
1363 w.start (3);
1360 send_ping (si); 1364 send_ping (si);
1361 w.start (3);
1362 } 1365 }
1363 else if (ev_now () < last_activity + ::conf.keepalive + 10) 1366 else if (when >= -10)
1364 // hold ondemand connections implicitly a few seconds longer 1367 // hold ondemand connections implicitly a few seconds longer
1365 // should delete octx, though, or something like that ;) 1368 // should delete octx, though, or something like that ;)
1366 w.start (last_activity + ::conf.keepalive + 10 - ev::now ()); 1369 w.start (when + 10);
1367 else 1370 else
1368 reset_connection (); 1371 reset_connection ();
1369} 1372}
1370 1373
1371void 1374void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines