diff --git a/vere/ames.c b/vere/ames.c index acdb3a674a..b8db287a84 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -58,10 +58,11 @@ _ames_czar(c3_y imp_y, c3_s* por_s) time_t now = time(0); *por_s = 13337 + imp_y; - if ( 0xffffffff == sam_u->imp_w[imp_y] ) { + if ( 0xffffffff == sam_u->imp_w[imp_y] + && (now - sam_u -> imp_t[imp_y]) < 300 ) { return 0; } - else if ( 0 == sam_u->imp_w[imp_y] + else if ( 0 == sam_u->imp_w[imp_y] || (now - sam_u->imp_t[imp_y]) > 300 ) { /* 5 minute TTL */ u3_noun nam = u3dc("scot", 'p', imp_y); c3_c* nam_c = u3r_string(nam); @@ -78,8 +79,11 @@ _ames_czar(c3_y imp_y, c3_s* por_s) if ( 0 != getaddrinfo(dns_c, 0, 0, &air_u) ) { uL(fprintf(uH, "ames: czar at %s: not found (a)\n", dns_c)); - sam_u->imp_w[imp_y] = 0xffffffff; - sam_u->imp_t[imp_y] = 0; + if ( sam_u->imp_w[imp_y] == 0 + || sam_u->imp_w[imp_y] == 0xffffffff ) { + sam_u->imp_w[imp_y] = 0xffffffff; + } /* else keep existing ip for 5 more minutes */ + sam_u->imp_t[imp_y] = now; return 0; } @@ -89,8 +93,11 @@ _ames_czar(c3_y imp_y, c3_s* por_s) while ( 1 ) { if ( !rai_u ) { uL(fprintf(uH, "ames: czar at %s: not found (b)\n", dns_c)); - sam_u->imp_w[imp_y] = 0xffffffff; - sam_u->imp_t[imp_y] = 0; + if ( sam_u->imp_w[imp_y] == 0 + || sam_u->imp_w[imp_y] == 0xffffffff ) { + sam_u->imp_w[imp_y] = 0xffffffff; + } /* else keep existing ip for 5 more minutes */ + sam_u->imp_t[imp_y] = now; return 0; } if ( (AF_INET == rai_u->ai_family) ) { @@ -100,7 +107,8 @@ _ames_czar(c3_y imp_y, c3_s* por_s) sam_u->imp_w[imp_y] = ntohl(add_u->sin_addr.s_addr); sam_u->imp_t[imp_y] = now; #if 1 - if ( sam_u->imp_w[imp_y] != old_w ) { + if ( sam_u->imp_w[imp_y] != old_w + && sam_u->imp_w[imp_y] != 0xffffffff ) { u3_noun wad = u3i_words(1, &sam_u->imp_w[imp_y]); u3_noun nam = u3dc("scot", c3__if, wad); c3_c* nam_c = u3r_string(nam);