Creating an ETS table in an ejabberd module

An ETS table is associated with a process.
When the process dies, the table is destroyed.

When starting an ejabberd module using the WebAdmin, the process that executes Module:start/2 is the ejabberd_http process.
As a summary, when the ejabberd_http process dies (the admin closes the browser, or a timeout happens),
the ETS table will be deleted!!

This problem doesn't happen if the module is defined in ejabberd.cfg,
because it is started by ejabberd itself and the table owner is a core ejabberd process that never dies.

So, don't create an ETS table if the code is executed by a process that may die when the table is still useful.

Solutions:
* If the module starts a process, create the ETS table in it
* Create a Mnesia table instead of ETS

Syndicate content