From: Michal 'vorner' Vaner Date: Thu, 25 Oct 2012 18:58:37 +0000 (+0200) Subject: [2209] Make ConfigurableClientList::reload a wrapper X-Git-Tag: trac2487_base~23^2~27^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ecabe80cbb2483d8057a83c84faeb84ce903b555;p=thirdparty%2Fkea.git [2209] Make ConfigurableClientList::reload a wrapper 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. --- diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc index 14ae96925d..474f7a7a35 100644 --- a/src/lib/datasrc/client_list.cc +++ b/src/lib/datasrc/client_list.cc @@ -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 {