@@ -757,6 +757,25 @@ static void triggerLoadOfLibraries()
757757 dummy.join ();
758758}
759759
760+ static bool updateZoneCache (Logr::log_t slog)
761+ {
762+ try {
763+ UeberBackend B;
764+ B.updateZoneCache ();
765+ }
766+ catch (PDNSException& e) {
767+ SLOG (g_log << Logger::Error << " PDNSException while filling the zone cache: " << e.reason << endl,
768+ slog->error (Logr::Error, e.reason , " PDNSException while filling the zone cache" ));
769+ return false ;
770+ }
771+ catch (std::exception& e) {
772+ SLOG (g_log << Logger::Error << " STL Exception while filling the zone cache: " << e.what () << endl,
773+ slog->error (Logr::Error, e.what (), " STL Exception while filling the zone cache" ));
774+ return false ;
775+ }
776+ return true ;
777+ }
778+
760779static void mainthread ()
761780{
762781 static std::shared_ptr<Logr::Logger> slog;
@@ -968,18 +987,7 @@ static void mainthread()
968987 // Setup the zone cache
969988 g_zoneCache.setRefreshInterval (::arg ().asNum (" zone-cache-refresh-interval" ));
970989 if (g_zoneCache.getRefreshInterval () != 0 ) {
971- try {
972- UeberBackend B;
973- B.updateZoneCache ();
974- }
975- catch (PDNSException& e) {
976- SLOG (g_log << Logger::Error << " PDNSException while filling the zone cache: " << e.reason << endl,
977- slog->error (Logr::Error, e.reason , " PDNSException while filling the zone cache" ));
978- exit (1 );
979- }
980- catch (std::exception& e) {
981- SLOG (g_log << Logger::Error << " STL Exception while filling the zone cache: " << e.what () << endl,
982- slog->error (Logr::Error, e.what (), " STL Exception while filling the zone cache" ));
990+ if (!updateZoneCache (slog)) {
983991 exit (1 );
984992 }
985993 }
@@ -1025,19 +1033,9 @@ static void mainthread()
10251033 if (zoneCacheRefresh != 0 ) {
10261034 zoneCacheUpdateSince += sleeptime;
10271035 if (zoneCacheUpdateSince >= zoneCacheRefresh) {
1028- try {
1029- UeberBackend B;
1030- B.updateZoneCache ();
1036+ if (updateZoneCache (slog)) {
10311037 zoneCacheUpdateSince = 0 ;
10321038 }
1033- catch (PDNSException& e) {
1034- SLOG (g_log << Logger::Error << " PDNSException while updating zone cache: " << e.reason << endl,
1035- slog->error (Logr::Error, e.reason , " PDNSException while updating the zone cache" ));
1036- }
1037- catch (std::exception& e) {
1038- SLOG (g_log << Logger::Error << " STL Exception while updating zone cache: " << e.what () << endl,
1039- slog->error (Logr::Error, e.what (), " STL Exception while updating the zone cache" ));
1040- }
10411039 }
10421040 }
10431041
0 commit comments