From: Leandro Lucarella Date: Tue, 4 Jul 2006 14:27:55 +0000 (+0000) Subject: Se conserva el TTL original en el cache. X-Git-Tag: svn_import~4 X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/commitdiff_plain/38c14daa3c920dad5d3201157661166860af2a8c Se conserva el TTL original en el cache. --- diff --git a/practicas/pipi/src/nameserver.cpp b/practicas/pipi/src/nameserver.cpp index 4d878b1..886a2fc 100644 --- a/practicas/pipi/src/nameserver.cpp +++ b/practicas/pipi/src/nameserver.cpp @@ -376,7 +376,7 @@ ResolvProtoResponse NameServer::query(const Name& n, const IPAddr& ip) #endif // Agrego a cache if (resp.ret == RP_RES_A) - cache[n] = CacheRecord(time(NULL) + resp.ttl, resp.ips); + cache[n] = CacheRecord(time(NULL) + resp.ttl, resp.ttl, resp.ips); return resp; } diff --git a/practicas/pipi/src/nameserver.h b/practicas/pipi/src/nameserver.h index 2dab7a3..fefa092 100644 --- a/practicas/pipi/src/nameserver.h +++ b/practicas/pipi/src/nameserver.h @@ -63,6 +63,8 @@ struct NameServer /// Cache de un registro struct CacheRecord { + /// Tiempo de expiración (segundos desde el epoch) + size_t expire; /// Time to live size_t ttl; /// Dirección IP del registro @@ -70,8 +72,8 @@ struct NameServer ipvec_t ips; /// Constructor CacheRecord(): ttl(0) {} - CacheRecord(size_t ttl, const ipvec_t& ips): - ttl(ttl), ips(ips) {} + CacheRecord(size_t expire, size_t ttl, const ipvec_t& ips): + expire(expire), ttl(ttl), ips(ips) {} }; /// Cache de records