Fix ames timer to actually work.

This commit is contained in:
C. Guy Yarvin 2014-04-23 10:02:36 -07:00
parent 72843c8955
commit 29ca4f9fe2
2 changed files with 8 additions and 0 deletions

View File

@ -204,6 +204,7 @@
uv_udp_t wax_u; // socket state
uv_timer_t tim_u; // network timer
u2_bean alm; // alarm on
c3_w law_w; // last wakeup, unix time
c3_s por_s; // public IPv4 port
c3_w imp_w[256]; // imperial IPs
} u2_ames;

View File

@ -228,7 +228,10 @@ u2_ames_ef_send(u2_noun lan, u2_noun pac)
static void
_ames_time_cb(uv_timer_t* tim_u, c3_i sas_i)
{
u2_ames* sam_u = &u2_Host.sam_u;
u2_lo_open();
sam_u->law_w = time(0);
{
u2_reck_plan
(u2A,
@ -363,6 +366,10 @@ u2_ames_io_poll()
(u2_yes == u2ud(u2t(wen))) )
{
c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen)));
c3_w lem_w = (time(0) - sam_u->law_w);
c3_w lef_w = (lem_w > 32) ? 0 : (32 - lem_w);
gap_d = c3_min(gap_d, (c3_d)(1000 * lef_w));
if ( u2_yes == sam_u->alm ) {
uv_timer_stop(&sam_u->tim_u);