From: JINMEI Tatuya Date: Thu, 25 Oct 2012 21:27:27 +0000 (-0700) Subject: [2212] use the new (staged) version of zone loading API from the builder thread X-Git-Tag: trac2487_base~23^2~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a6ca17646b6bdf23f36d523bb56f3bb91e1dbf39;p=thirdparty%2Fkea.git [2212] use the new (staged) version of zone loading API from the builder thread --- diff --git a/src/bin/auth/datasrc_clients_mgr.h b/src/bin/auth/datasrc_clients_mgr.h index 0392dd6de9..958de74cc9 100644 --- a/src/bin/auth/datasrc_clients_mgr.h +++ b/src/bin/auth/datasrc_clients_mgr.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -501,10 +502,41 @@ DataSrcClientsBuilderBase::doLoadZone( found->second; assert(client_list); - datasrc::ConfigurableClientList::ReloadResult result; try { - typename MutexType::Locker locker(*map_mutex_); - result = client_list->reload(origin); + const datasrc::ConfigurableClientList::ZoneWriterPair writerpair = + client_list->getCachedZoneWriter(origin); + switch (writerpair.first) { + case datasrc::ConfigurableClientList::ZONE_NOT_FOUND: + isc_throw(InternalCommandError, "failed to load zone " << origin + << "/" << rrclass << ": not found in any configured " + "data source."); + case datasrc::ConfigurableClientList::ZONE_NOT_CACHED: + isc_throw(InternalCommandError, "failed to load zone " << origin + << "/" << rrclass << ": not served from memory"); + case datasrc::ConfigurableClientList::CACHE_DISABLED: + // This is an internal error. Auth server must have the cache + // enabled. + isc_throw(InternalCommandError, "failed to load zone " << origin + << "/" << rrclass << ": internal failure, in-memory cache " + "is somehow disabled"); + default: + break; + } + + boost::shared_ptr zwriter = + writerpair.second; + zwriter->load(); // this can take time but doesn't cause a race + { // install() can cause a race and must be in a critical section + typename MutexType::Locker locker(*map_mutex_); + zwriter->install(); + } + LOG_DEBUG(auth_logger, DBG_AUTH_OPS, + AUTH_DATASRC_CLIENTS_BUILDER_LOAD_ZONE) + .arg(origin).arg(rrclass); + + zwriter->cleanup(); + } catch (const InternalCommandError& ex) { + throw; } catch (const isc::Exception& ex) { // We catch our internal exceptions (which will be just ignored) and // propagated others (which should generally be considered fatal and @@ -513,27 +545,6 @@ DataSrcClientsBuilderBase::doLoadZone( "/" << rrclass << ": error occurred in reload: " << ex.what()); } - switch (result) { - case datasrc::ConfigurableClientList::ZONE_RELOADED: - // Everything worked fine. - LOG_DEBUG(auth_logger, DBG_AUTH_OPS, - AUTH_DATASRC_CLIENTS_BUILDER_LOAD_ZONE) - .arg(origin).arg(rrclass); - break; - case datasrc::ConfigurableClientList::ZONE_NOT_FOUND: - isc_throw(InternalCommandError, "failed to load zone " << origin - << "/" << rrclass << ": not found in any configured " - "data source."); - case datasrc::ConfigurableClientList::ZONE_NOT_CACHED: - isc_throw(InternalCommandError, "failed to load zone " << origin - << "/" << rrclass << ": not served from memory"); - case datasrc::ConfigurableClientList::CACHE_DISABLED: - // This is an internal error. Auth server must have the cache - // enabled. - isc_throw(InternalCommandError, "failed to load zone " << origin - << "/" << rrclass << ": internal failure, in-memory cache " - "is somehow disabled"); - } } } // namespace datasrc_clientmgr_internal