]> git.llucax.com Git - z.facultad/75.74/practicos.git/commitdiff
Agrega records al cache.
authorLeandro Lucarella <llucax@gmail.com>
Tue, 4 Jul 2006 14:07:45 +0000 (14:07 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Tue, 4 Jul 2006 14:07:45 +0000 (14:07 +0000)
practicas/pipi/src/nameserver.cpp

index 23a2e237c938c35f1af773956a532c536c985801..82ca2af5da5546524588b59e01cf714968fd4b94 100644 (file)
@@ -309,7 +309,6 @@ ResolvProtoResponse NameServer::resolv_recursive(const Name& n)
             std::cerr << "NameServer::resolv_recursive -> gotcha! "
                 << rpr << "\n";
 #endif
-            // TODO agregar a cache
             break;
     }
     return rpr; // Devuelvo el A o NOTFOUND
@@ -346,7 +345,6 @@ ResolvProtoResponse NameServer::resolv_recursive_r(const Name& n,
                 std::cerr << "NameServer::resolv_recursive_r -> gotcha! "
                     << r << "\n";
 #endif
-                // TODO agregar a cache
                 return r; // Gotcha!
         }
     }
@@ -376,6 +374,9 @@ ResolvProtoResponse NameServer::query(const Name& n, const IPAddr& ip)
     std::cerr << "NameServer::query -> recibido " << resp << " de "
         << ip << "\n";
 #endif
+    // Agrego a cache
+    if (resp.ret == RP_RES_A)
+        cache[n] = CacheRecord(time(NULL) + resp.ttl, resp.ips);
     return resp;
 }