From 53c06533d30647db0abbe8e29c8a3205229420e1 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 8 Jul 2010 18:49:37 +0200 Subject: [PATCH] Better scope for the hook driver name, removed unused variable --- include/HookManager.h | 33 ++++++++++++++++----------------- src/hm/HookManager.cc | 32 ++++++++++++++++---------------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/include/HookManager.h b/include/HookManager.h index 453d371dc5..5495cbd549 100644 --- a/include/HookManager.h +++ b/include/HookManager.h @@ -31,20 +31,15 @@ class HookManager : public MadManager, public ActionListener public: HookManager(vector& _mads, VirtualMachinePool * _vmpool) - :MadManager(_mads),vmpool(_vmpool) + :MadManager(_mads),vmpool(_vmpool) { am.addListener(this); }; ~HookManager(){}; - - /** - * Generic name for the Hook driver - */ - static const char * hook_driver_name; /** - * This functions starts the associated listener thread, and creates a + * This functions starts the associated listener thread, and creates a * new thread for the Hook Manager. This thread will wait in * an action loop till it receives ACTION_FINALIZE. * @return 0 on success. @@ -61,12 +56,12 @@ public: }; /** - * + * */ void load_mads(int uid=0); /** - * + * */ void finalize() { @@ -74,39 +69,43 @@ public: }; /** - * Returns a pointer to a Information Manager MAD. The driver is + * Returns a pointer to a Information Manager MAD. The driver is * searched by its name and owned by oneadmin with uid=0. * @param name of the driver - * @return the Hook driver owned by uid 0, with attribute "NAME" equal to + * @return the Hook driver owned by uid 0, with attribute "NAME" equal to * name or 0 in not found */ const HookManagerDriver * get() { string name("NAME"); - string hook_name(hook_driver_name); - + return static_cast (MadManager::get(0,name,hook_driver_name)); }; - + private: + /** + * Generic name for the Hook driver + */ + static const char * hook_driver_name; + /** * Pointer to the VirtualMachine Pool */ VirtualMachinePool * vmpool; - + /** * Thread id for the HookManager */ pthread_t hm_thread; - + /** * Action engine for the Manager */ ActionManager am; /** - * Function to execute the Manager action loop method within a new pthread + * Function to execute the Manager action loop method within a new pthread * (requires C linkage) */ friend void * hm_action_loop(void *arg); diff --git a/src/hm/HookManager.cc b/src/hm/HookManager.cc index 3071249761..1fa91e9dc1 100644 --- a/src/hm/HookManager.cc +++ b/src/hm/HookManager.cc @@ -34,28 +34,28 @@ extern "C" void * hm_action_loop(void *arg) NebulaLog::log("HKM",Log::INFO,"Hook Manager started."); hm = static_cast(arg); - + hm->am.loop(0,0); NebulaLog::log("HKM",Log::INFO,"Hook Manager stopped."); - + return 0; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void HookManager::load_mads(int uid) +void HookManager::load_mads(int uid) { HookManagerDriver * hm_mad; ostringstream oss; const VectorAttribute * vattr; int rc; - + NebulaLog::log("HKM",Log::INFO,"Loading Hook Manager driver."); - + vattr = static_cast(mad_conf[0]); - + if ( vattr == 0 ) { NebulaLog::log("HKM",Log::INFO,"Failed to load Hook Manager driver."); @@ -63,18 +63,18 @@ void HookManager::load_mads(int uid) } VectorAttribute hook_conf("HOOK_MAD",vattr->value()); - + hook_conf.replace("NAME",hook_driver_name); - + hm_mad = new HookManagerDriver(0,hook_conf.value(),false,vmpool); - + rc = add(hm_mad); - + if ( rc == 0 ) { - oss.str(""); + oss.str(""); oss << "\tHook Manager loaded"; - + NebulaLog::log("HKM",Log::INFO,oss); } } @@ -95,7 +95,7 @@ int HookManager::start() } NebulaLog::log("HKM",Log::INFO,"Starting Hook Manager..."); - + pthread_attr_init (&pattr); pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE); @@ -112,14 +112,14 @@ void HookManager::do_action(const string &action, void * arg) if (action == ACTION_FINALIZE) { NebulaLog::log("HKM",Log::INFO,"Stopping Hook Manager..."); - - MadManager::stop(); + + MadManager::stop(); } else { ostringstream oss; oss << "Unknown action name: " << action; - + NebulaLog::log("HKM", Log::ERROR, oss); } }