efl_net_server_ssl: monitor context del and unref on destructor.

we're leaking ssl_ctx on destruction, also monitor it so we don't
access stale data.
This commit is contained in:
Gustavo Sverzut Barbieri 2016-12-08 15:25:11 -02:00
parent 7c7ea6be06
commit 17e0204ab3
1 changed files with 17 additions and 0 deletions

View File

@ -150,6 +150,14 @@ _efl_net_server_ssl_efl_object_constructor(Eo *o, Efl_Net_Server_Ssl_Data *pd)
return o;
}
static void
_efl_net_server_ssl_ctx_del(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *o = data;
Efl_Net_Server_Ssl_Data *pd = efl_data_scope_get(o, MY_CLASS);
pd->ssl_ctx = NULL;
}
EOLIAN void
_efl_net_server_ssl_efl_object_destructor(Eo *o, Efl_Net_Server_Ssl_Data *pd)
{
@ -159,6 +167,13 @@ _efl_net_server_ssl_efl_object_destructor(Eo *o, Efl_Net_Server_Ssl_Data *pd)
pd->server = NULL;
}
if (pd->ssl_ctx)
{
efl_event_callback_del(pd->ssl_ctx, EFL_EVENT_DEL, _efl_net_server_ssl_ctx_del, o);
efl_unref(pd->ssl_ctx);
pd->ssl_ctx = NULL;
}
efl_destructor(efl_super(o, MY_CLASS));
}
@ -170,6 +185,8 @@ _efl_net_server_ssl_ssl_context_set(Eo *o EINA_UNUSED, Efl_Net_Server_Ssl_Data *
if (pd->ssl_ctx == ssl_ctx) return;
efl_unref(pd->ssl_ctx);
pd->ssl_ctx = efl_ref(ssl_ctx);
if (ssl_ctx)
efl_event_callback_add(ssl_ctx, EFL_EVENT_DEL, _efl_net_server_ssl_ctx_del, o);
}
EOLIAN static Eo *