MT#65612 RegThread: lifetime hardening

If the owner of the `RegThread` (`RegistrationAgentFactory`)
was asked to be destructed, make the destroy process
of the reg thread more ordered as well.

That makes the thread to stop as soon as the app factory
begins its own destruction.

This will help to avoid a possible way to end up with
a stale (or invalid) DI factory ptr.

E.g.: `RegThread` keeps on running, while all the plugins
are being torn down by that time already. In this case
the `RegThread` can simply call `getFactory4Di()` or `di_f->getInstance()`
way after the registrar_client is already partially destroyed.

Change-Id: I10e38174d3856e19f2696f8d874ea166e0a035a8
mr26.2
Donat Zenichev 2 weeks ago
parent e9995a63f9
commit a654c9c01d

@ -50,11 +50,6 @@
EXPORT_SESSION_FACTORY(RegistrationAgentFactory,MOD_NAME);
RegistrationAgentFactory::RegistrationAgentFactory(const string& _app_name)
: AmSessionFactory(_app_name)
{
}
int RegistrationAgentFactory::onLoad()
{
AmConfigReader cfg;

@ -49,7 +49,7 @@ struct RegInfo {
class RegThread : public AmThread {
vector<RegInfo> 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<string,string>& app_params);

Loading…
Cancel
Save