diff --git a/apps/reg_agent/RegistrationAgent.cpp b/apps/reg_agent/RegistrationAgent.cpp index 0130de28..9f3e0c98 100644 --- a/apps/reg_agent/RegistrationAgent.cpp +++ b/apps/reg_agent/RegistrationAgent.cpp @@ -50,11 +50,6 @@ EXPORT_SESSION_FACTORY(RegistrationAgentFactory,MOD_NAME); -RegistrationAgentFactory::RegistrationAgentFactory(const string& _app_name) - : AmSessionFactory(_app_name) -{ -} - int RegistrationAgentFactory::onLoad() { AmConfigReader cfg; diff --git a/apps/reg_agent/RegistrationAgent.h b/apps/reg_agent/RegistrationAgent.h index 6e715d4d..1505e54e 100644 --- a/apps/reg_agent/RegistrationAgent.h +++ b/apps/reg_agent/RegistrationAgent.h @@ -49,7 +49,7 @@ struct RegInfo { class RegThread : public AmThread { vector registrations; - + void create_registration(RegInfo& ri); bool check_registration(const RegInfo& ri); @@ -64,11 +64,22 @@ class RegThread : public AmThread { class RegistrationAgentFactory: public AmSessionFactory { - RegThread dialer; + RegThread dialer; public: - RegistrationAgentFactory(const string& _app_name); - + RegistrationAgentFactory(const string& _app_name) + : AmSessionFactory(_app_name) + { + DBG("Add new reg agent factory.\n"); + } + ~RegistrationAgentFactory() + { + /* makes the thread stop as soon as the app factory begins its destruction */ + DBG("Requested the reg agent thread to stop.\n"); + dialer.stop(); + dialer.join(); + } + int onLoad(); AmSession* onInvite(const AmSipRequest& req, const string& app_name, const map& app_params);