forked from Mirrors/freeswitch
make modules unbind events and un-reserve subclasses on module unload
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8898 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
ffb2e317bb
commit
2f94f73921
@ -75,6 +75,7 @@ static struct {
|
|||||||
uint32_t id_pool;
|
uint32_t id_pool;
|
||||||
int32_t running;
|
int32_t running;
|
||||||
uint32_t threads;
|
uint32_t threads;
|
||||||
|
switch_event_node_t *node;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -5258,7 +5259,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load)
|
|||||||
switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
|
switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
|
||||||
|
|
||||||
/* Subscribe to presence request events */
|
/* Subscribe to presence request events */
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
@ -5283,6 +5284,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown)
|
|||||||
switch_yield(100000);
|
switch_yield(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_event_unbind(&globals.node);
|
||||||
|
switch_event_free_subclass(CONF_EVENT_MAINT);
|
||||||
|
|
||||||
/* free api interface help ".syntax" field string */
|
/* free api interface help ".syntax" field string */
|
||||||
switch_safe_free(api_syntax);
|
switch_safe_free(api_syntax);
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ static struct {
|
|||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
int auto_reload;
|
int auto_reload;
|
||||||
int timeout;
|
int timeout;
|
||||||
|
switch_event_node_t *node;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_root, globals.root);
|
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_root, globals.root);
|
||||||
@ -834,7 +835,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_enum_load)
|
|||||||
do_load();
|
do_load();
|
||||||
|
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_TERM;
|
return SWITCH_STATUS_TERM;
|
||||||
}
|
}
|
||||||
@ -855,6 +856,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_enum_load)
|
|||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_enum_shutdown)
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_enum_shutdown)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
switch_event_unbind(&globals.node);
|
||||||
|
|
||||||
if (globals.pool) {
|
if (globals.pool) {
|
||||||
switch_core_destroy_memory_pool(&globals.pool);
|
switch_core_destroy_memory_pool(&globals.pool);
|
||||||
}
|
}
|
||||||
|
@ -2955,5 +2955,5 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voicemail_load)
|
|||||||
* c-basic-offset:4
|
* c-basic-offset:4
|
||||||
* End:
|
* End:
|
||||||
* For VIM:
|
* For VIM:
|
||||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
|
||||||
*/
|
*/
|
||||||
|
@ -103,6 +103,11 @@ static struct {
|
|||||||
int running;
|
int running;
|
||||||
int handles;
|
int handles;
|
||||||
char guess_ip[80];
|
char guess_ip[80];
|
||||||
|
switch_event_node_t *in_node;
|
||||||
|
switch_event_node_t *probe_node;
|
||||||
|
switch_event_node_t *out_node;
|
||||||
|
switch_event_node_t *roster_node;
|
||||||
|
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
struct mdl_profile {
|
struct mdl_profile {
|
||||||
@ -1755,22 +1760,22 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dingaling_load)
|
|||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.in_node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.probe_node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.out_node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, roster_event_handler, NULL)
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, roster_event_handler, NULL, &globals.roster_node)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
@ -1867,6 +1872,16 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dingaling_shutdown)
|
|||||||
ldl_global_destroy();
|
ldl_global_destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_event_free_subclass(DL_EVENT_LOGIN_SUCCESS);
|
||||||
|
switch_event_free_subclass(DL_EVENT_LOGIN_FAILURE);
|
||||||
|
switch_event_free_subclass(DL_EVENT_CONNECTED);
|
||||||
|
switch_event_unbind(&globals.in_node);
|
||||||
|
switch_event_unbind(&globals.probe_node);
|
||||||
|
switch_event_unbind(&globals.out_node);
|
||||||
|
switch_event_unbind(&globals.roster_node);
|
||||||
|
|
||||||
|
|
||||||
switch_core_hash_destroy(&globals.profile_hash);
|
switch_core_hash_destroy(&globals.profile_hash);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1961,36 +1961,36 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for profiles to start\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for profiles to start\n");
|
||||||
switch_yield(1500000);
|
switch_yield(1500000);
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL, &mod_sofia_globals.custom_node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_TERM;
|
return SWITCH_STATUS_TERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL)
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL, &mod_sofia_globals.in_node)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL)
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL, &mod_sofia_globals.out_node)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL)
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL, &mod_sofia_globals.probe_node)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL)
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL, &mod_sofia_globals.roster_node)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_MESSAGE_WAITING, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_mwi_event_handler, NULL)
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_WAITING, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_mwi_event_handler, NULL, &mod_sofia_globals.mwi_node)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
@ -2030,6 +2030,13 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown)
|
|||||||
}
|
}
|
||||||
switch_mutex_unlock(mod_sofia_globals.mutex);
|
switch_mutex_unlock(mod_sofia_globals.mutex);
|
||||||
|
|
||||||
|
switch_event_unbind(&mod_sofia_globals.in_node);
|
||||||
|
switch_event_unbind(&mod_sofia_globals.probe_node);
|
||||||
|
switch_event_unbind(&mod_sofia_globals.out_node);
|
||||||
|
switch_event_unbind(&mod_sofia_globals.roster_node);
|
||||||
|
switch_event_unbind(&mod_sofia_globals.custom_node);
|
||||||
|
switch_event_unbind(&mod_sofia_globals.mwi_node);
|
||||||
|
|
||||||
while (mod_sofia_globals.threads) {
|
while (mod_sofia_globals.threads) {
|
||||||
switch_yield(1000);
|
switch_yield(1000);
|
||||||
if (++sanity >= 10000) {
|
if (++sanity >= 10000) {
|
||||||
|
@ -209,6 +209,12 @@ struct mod_sofia_globals {
|
|||||||
switch_queue_t *mwi_queue;
|
switch_queue_t *mwi_queue;
|
||||||
struct sofia_private destroy_private;
|
struct sofia_private destroy_private;
|
||||||
struct sofia_private keep_private;
|
struct sofia_private keep_private;
|
||||||
|
switch_event_node_t *in_node;
|
||||||
|
switch_event_node_t *probe_node;
|
||||||
|
switch_event_node_t *out_node;
|
||||||
|
switch_event_node_t *roster_node;
|
||||||
|
switch_event_node_t *custom_node;
|
||||||
|
switch_event_node_t *mwi_node;
|
||||||
};
|
};
|
||||||
extern struct mod_sofia_globals mod_sofia_globals;
|
extern struct mod_sofia_globals mod_sofia_globals;
|
||||||
|
|
||||||
|
@ -1184,6 +1184,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
route = switch_core_session_strdup(tech_pvt->session, route + 9);
|
route = switch_core_session_strdup(tech_pvt->session, route + 9);
|
||||||
|
switch_assert(route);
|
||||||
|
|
||||||
for (p = route; p && *p ; p++) {
|
for (p = route; p && *p ; p++) {
|
||||||
if (*p == '>' || *p == ';') {
|
if (*p == '>' || *p == ';') {
|
||||||
|
@ -1413,7 +1413,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
|||||||
char *sticky = NULL;
|
char *sticky = NULL;
|
||||||
|
|
||||||
if (is_nat) {
|
if (is_nat) {
|
||||||
const char *ipv6 = strchr(network_ip, ':');
|
ipv6 = strchr(network_ip, ':');
|
||||||
sticky = switch_mprintf("sip:%s@%s%s%s:%d",
|
sticky = switch_mprintf("sip:%s@%s%s%s:%d",
|
||||||
contact_user,
|
contact_user,
|
||||||
ipv6 ? "[" : "",
|
ipv6 ? "[" : "",
|
||||||
|
@ -56,11 +56,12 @@ static struct {
|
|||||||
int rotate;
|
int rotate;
|
||||||
int debug;
|
int debug;
|
||||||
cdr_leg_t legs;
|
cdr_leg_t legs;
|
||||||
|
switch_event_node_t *node;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_csv_load);
|
SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_csv_load);
|
||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_csv_shutdown);
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_csv_shutdown);
|
||||||
SWITCH_MODULE_DEFINITION(mod_cdr_csv, mod_cdr_csv_load, NULL, NULL);
|
SWITCH_MODULE_DEFINITION(mod_cdr_csv, mod_cdr_csv_load, mod_cdr_csv_shutdown, NULL);
|
||||||
|
|
||||||
static off_t fd_size(int fd)
|
static off_t fd_size(int fd)
|
||||||
{
|
{
|
||||||
@ -363,7 +364,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_csv_load)
|
|||||||
{
|
{
|
||||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
@ -385,6 +386,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_csv_shutdown)
|
|||||||
{
|
{
|
||||||
|
|
||||||
globals.shutdown = 1;
|
globals.shutdown = 1;
|
||||||
|
switch_event_unbind(&globals.node);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ static struct {
|
|||||||
switch_hash_t *event_hash;
|
switch_hash_t *event_hash;
|
||||||
uint8_t event_list[SWITCH_EVENT_ALL + 1];
|
uint8_t event_list[SWITCH_EVENT_ALL + 1];
|
||||||
int running;
|
int running;
|
||||||
|
switch_event_node_t *node;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_address, globals.address);
|
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_address, globals.address);
|
||||||
@ -261,6 +262,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_multicast_shutdown)
|
|||||||
globals.udp_socket = NULL;
|
globals.udp_socket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_event_unbind(&globals.node);
|
||||||
|
switch_event_free_subclass(MULTICAST_EVENT);
|
||||||
|
|
||||||
switch_core_hash_destroy(&globals.event_hash);
|
switch_core_hash_destroy(&globals.event_hash);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
@ -106,6 +106,11 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_pass, prefs.password);
|
|||||||
static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj);
|
static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj);
|
||||||
static void launch_listener_thread(listener_t *listener);
|
static void launch_listener_thread(listener_t *listener);
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
switch_event_node_t *node;
|
||||||
|
} globals;
|
||||||
|
|
||||||
|
|
||||||
static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_level_t level)
|
static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_level_t level)
|
||||||
{
|
{
|
||||||
listener_t *l;
|
listener_t *l;
|
||||||
@ -326,6 +331,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_socket_shutdown)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch_event_unbind(&globals.node);
|
||||||
|
|
||||||
switch_mutex_lock(listen_list.mutex);
|
switch_mutex_lock(listen_list.mutex);
|
||||||
for (l = listen_list.listeners; l; l = l->next) {
|
for (l = listen_list.listeners; l; l = l->next) {
|
||||||
@ -1357,7 +1363,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
|
|||||||
|
|
||||||
listen_list.ready = 1;
|
listen_list.ready = 1;
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@ static struct {
|
|||||||
sw_discovery discovery;
|
sw_discovery discovery;
|
||||||
sw_discovery_publish_id disc_id;
|
sw_discovery_publish_id disc_id;
|
||||||
switch_mutex_t *zc_lock;
|
switch_mutex_t *zc_lock;
|
||||||
|
switch_event_node_t *publish_node;
|
||||||
|
switch_event_node_t *unpublish_node;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
|
|
||||||
@ -218,12 +220,12 @@ static switch_status_t load_config(void)
|
|||||||
return SWITCH_STATUS_MEMERR;
|
return SWITCH_STATUS_MEMERR;
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(var, "publish") && !strcasecmp(val, "yes")) {
|
} else if (!strcasecmp(var, "publish") && !strcasecmp(val, "yes")) {
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.publish_node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.unpublish_node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
@ -248,6 +250,12 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_zeroconf_shutdown)
|
|||||||
RUNNING = -1;
|
RUNNING = -1;
|
||||||
switch_yield(100000);
|
switch_yield(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_event_unbind(&globals.publish_node);
|
||||||
|
switch_event_unbind(&globals.unpublish_node);
|
||||||
|
switch_event_free_subclass(MY_EVENT_PUBLISH);
|
||||||
|
switch_event_free_subclass(MY_EVENT_UNPUBLISH);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,10 +273,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_zeroconf_load)
|
|||||||
return SWITCH_STATUS_TERM;
|
return SWITCH_STATUS_TERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (load_config() != SWITCH_STATUS_SUCCESS) {
|
|
||||||
return SWITCH_STATUS_TERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (switch_event_reserve_subclass(MY_EVENT_PUBLISH) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_reserve_subclass(MY_EVENT_PUBLISH) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
@ -279,6 +283,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_zeroconf_load)
|
|||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (load_config() != SWITCH_STATUS_SUCCESS) {
|
||||||
|
return SWITCH_STATUS_TERM;
|
||||||
|
}
|
||||||
|
|
||||||
/* connect my internal structure to the blank pointer passed to me */
|
/* connect my internal structure to the blank pointer passed to me */
|
||||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||||
|
|
||||||
|
@ -38,11 +38,14 @@ SWITCH_BEGIN_EXTERN_C
|
|||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include "mod_lua_extra.h"
|
#include "mod_lua_extra.h"
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load);
|
SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load);
|
||||||
SWITCH_MODULE_DEFINITION(mod_lua, mod_lua_load, NULL, NULL);
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lua_shutdown);
|
||||||
|
|
||||||
|
SWITCH_MODULE_DEFINITION(mod_lua, mod_lua_load, mod_lua_shutdown, NULL);
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
char *xml_handler;
|
char *xml_handler;
|
||||||
|
switch_event_node_t *node;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
int luaopen_freeswitch(lua_State * L);
|
int luaopen_freeswitch(lua_State * L);
|
||||||
@ -389,7 +392,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load)
|
|||||||
switch_api_interface_t *api_interface;
|
switch_api_interface_t *api_interface;
|
||||||
switch_application_interface_t *app_interface;
|
switch_application_interface_t *app_interface;
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL)
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL, &globals.node)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
@ -411,6 +414,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lua_shutdown)
|
||||||
|
{
|
||||||
|
switch_event_unbind(&globals.node);
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
|
@ -95,9 +95,9 @@ static struct {
|
|||||||
FILE *gOutFile;
|
FILE *gOutFile;
|
||||||
int stackDummy;
|
int stackDummy;
|
||||||
JSRuntime *rt;
|
JSRuntime *rt;
|
||||||
|
switch_event_node_t *node;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
|
|
||||||
static JSClass global_class = {
|
static JSClass global_class = {
|
||||||
"Global", JSCLASS_HAS_PRIVATE,
|
"Global", JSCLASS_HAS_PRIVATE,
|
||||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||||
@ -3564,7 +3564,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL)
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL, &globals.node)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
@ -3586,6 +3586,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load)
|
|||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown)
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown)
|
||||||
{
|
{
|
||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
|
switch_event_unbind(&globals.node);
|
||||||
switch_core_hash_destroy(&module_manager.mod_hash);
|
switch_core_hash_destroy(&module_manager.mod_hash);
|
||||||
switch_core_hash_destroy(&module_manager.load_hash);
|
switch_core_hash_destroy(&module_manager.load_hash);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
@ -46,6 +46,7 @@ static switch_hash_t *profile_hash = NULL;
|
|||||||
static struct {
|
static struct {
|
||||||
int rotate;
|
int rotate;
|
||||||
switch_mutex_t *mutex;
|
switch_mutex_t *mutex;
|
||||||
|
switch_event_node_t *node;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
struct logfile_profile {
|
struct logfile_profile {
|
||||||
@ -341,7 +342,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_logfile_load)
|
|||||||
}
|
}
|
||||||
switch_core_hash_init(&profile_hash, module_pool);
|
switch_core_hash_init(&profile_hash, module_pool);
|
||||||
|
|
||||||
if (switch_event_bind(modname, SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_bind_removable(modname, SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
@ -383,6 +384,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_logfile_shutdown)
|
|||||||
/* TODO: Need to finish processing pending log messages before we close the file handle */
|
/* TODO: Need to finish processing pending log messages before we close the file handle */
|
||||||
|
|
||||||
//switch_file_close(globals->log_afd);
|
//switch_file_close(globals->log_afd);
|
||||||
|
switch_event_unbind(&globals.node);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user