]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2209] Make ConfigurableClientList::reload a wrapper
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Thu, 25 Oct 2012 18:58:37 +0000 (20:58 +0200)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Thu, 25 Oct 2012 18:59:27 +0000 (20:59 +0200)
Since the function is to reload and we provide an object that can
reload, we just get one and call it. It is just to avoid duplicate code.

src/lib/datasrc/client_list.cc

index 14ae96925daad36ce77bb960d159c0a8d2b33dc0..474f7a7a3513235e0e21735cb3b3a5979ec8533e 100644 (file)
@@ -341,43 +341,17 @@ ConfigurableClientList::findInternal(MutableResult& candidate,
     // and the need_updater parameter is true, get the zone there.
 }
 
+// We still provide this method for backward compatibility. But to not have
+// duplicate code, it is a thin wrapper around getCachedZoneWriter only.
 ConfigurableClientList::ReloadResult
 ConfigurableClientList::reload(const Name& name) {
-    if (!allow_cache_) {
-        return (CACHE_DISABLED);
-    }
-    // Try to find the correct zone.
-    MutableResult result;
-    findInternal(result, name, true, true);
-    if (!result.finder) {
-        return (ZONE_NOT_FOUND);
-    }
-    // Try to convert the finder to in-memory one. If it is the cache,
-    // it should work.
-    // It is of a different type or there's no cache.
-    if (!result.info->cache_) {
-        return (ZONE_NOT_CACHED);
-    }
-    DataSourceClient* client(result.info->data_src_client_);
-    if (client) {
-        // Now do the final reload. If it does not exist in client,
-        // DataSourceError is thrown, which is exactly the result what we
-        // want, so no need to handle it.
-        ZoneIteratorPtr iterator(client->getIterator(name));
-        if (!iterator) {
-            isc_throw(isc::Unexpected, "Null iterator from " << name);
-        }
-        result.info->cache_->load(name, *iterator);
-    } else {
-        // The MasterFiles special case
-        const string filename(result.info->cache_->getFileName(name));
-        if (filename.empty()) {
-            isc_throw(isc::Unexpected, "Confused about missing both filename "
-                      "and data source");
-        }
-        result.info->cache_->load(name, filename);
+    ZoneWriterPair result(getCachedZoneWriter(name));
+    if (result.second) {
+        result.second->load();
+        result.second->install();
+        result.second->cleanup();
     }
-    return (ZONE_RELOADED);
+    return (result.first);
 }
 
 namespace {