From f76bbf01a4e02fabd55ed38fba28e3acb7ab9036 Mon Sep 17 00:00:00 2001 From: Bernhard Amann Date: Mon, 6 Feb 2012 13:15:01 -0800 Subject: [PATCH] fix CreateBackend function - the way that the right backend was chosen & backends were initialized did not make sense... --- src/logging/Manager.cc | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index add10b3f10..e8d732d84a 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -142,12 +142,12 @@ WriterBackend* Manager::CreateBackend(WriterFrontend* frontend, bro_int_t type) return 0; } - if ( ld->type == type ) - break; - - if ( ! ld->factory ) - // Oops, we can't instantiate this guy. - return 0; + if ( ld->type != type ) + { + // no, didn't find the right one... + ++ld; + continue; + } // If the writer has an init function, call it. if ( ld->init ) @@ -157,17 +157,24 @@ WriterBackend* Manager::CreateBackend(WriterFrontend* frontend, bro_int_t type) // call it again later. ld->init = 0; else + { // Init failed, disable by deleting factory // function. ld->factory = 0; - DBG_LOG(DBG_LOGGING, "failed to init writer class %s", - ld->name); + DBG_LOG(DBG_LOGGING, "failed to init writer class %s", + ld->name); - return false; + return false; + } } - ++ld; + if ( ! ld->factory ) + // Oops, we can't instantiate this guy. + return 0; + + // all done. break. + break; } assert(ld->factory);