summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2015-08-19 17:06:51 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2015-08-19 17:06:51 -0500
commitaacb46b56ae684d8f5d8affab31d9c45b149e733 (patch)
treefef7820e5d21c7d0d8d065865fd4cbe42a1f966a
parent26fca72837e969ed63780f337d26263f66e5dc64 (diff)
parent03eb6cbc10df61064fda2a3890d82ef04f3a0c6a (diff)
Merge "res_ari_events: Fix shutdown ref leak."
-rw-r--r--res/ari/resource_events.c19
-rw-r--r--res/ari/resource_events.h7
-rw-r--r--res/res_ari_events.c1
-rw-r--r--rest-api-templates/ari_resource.h.mustache11
4 files changed, 31 insertions, 7 deletions
diff --git a/res/ari/resource_events.c b/res/ari/resource_events.c
index f1342b7fa..deb7f9cc0 100644
--- a/res/ari/resource_events.c
+++ b/res/ari/resource_events.c
@@ -103,12 +103,12 @@ static void stasis_app_message_handler(
msg_type,
msg_application);
} else if (!session->ws_session) {
- /* If the websocket is NULL, the message goes to the queue */
- AST_VECTOR_APPEND(&session->message_queue, message);
- ast_log(LOG_WARNING,
- "Queued '%s' message for Stasis app '%s'; websocket is not ready\n",
- msg_type,
- msg_application);
+ /* If the websocket is NULL, the message goes to the queue */
+ AST_VECTOR_APPEND(&session->message_queue, message);
+ ast_log(LOG_WARNING,
+ "Queued '%s' message for Stasis app '%s'; websocket is not ready\n",
+ msg_type,
+ msg_application);
} else {
/* We are ready to publish the message */
ast_ari_websocket_session_write(session->ws_session, message);
@@ -426,13 +426,18 @@ static int event_session_alloc(struct ast_tcptls_session_instance *ser,
return 0;
}
+void ast_ari_websocket_events_event_websocket_dtor(void)
+{
+ ao2_cleanup(event_session_registry);
+ event_session_registry = NULL;
+}
+
int ast_ari_websocket_events_event_websocket_init(void)
{
/* Try to instantiate the registry */
event_session_registry = ao2_container_alloc(EVENT_SESSION_NUM_BUCKETS,
event_session_hash,
event_session_compare);
-
if (!event_session_registry) {
/* This is bad, bad. */
ast_log(LOG_WARNING,
diff --git a/res/ari/resource_events.h b/res/ari/resource_events.h
index bc763ebd3..aa1e3dfd6 100644
--- a/res/ari/resource_events.h
+++ b/res/ari/resource_events.h
@@ -60,6 +60,13 @@ int ast_ari_websocket_events_event_websocket_init(void);
/*!
* \brief WebSocket connection for events.
*
+ * \return Nothing
+ */
+void ast_ari_websocket_events_event_websocket_dtor(void);
+
+/*!
+ * \brief WebSocket connection for events.
+ *
* \param ser HTTP TCP/TLS Server Session
* \param headers HTTP headers
* \param args Swagger parameters
diff --git a/res/res_ari_events.c b/res/res_ari_events.c
index bf33aeaff..4b2b151aa 100644
--- a/res/res_ari_events.c
+++ b/res/res_ari_events.c
@@ -462,6 +462,7 @@ static int unload_module(void)
ast_ari_remove_handler(&events);
ao2_cleanup(events.ws_server);
events.ws_server = NULL;
+ ast_ari_websocket_events_event_websocket_dtor();
stasis_app_unref();
return 0;
}
diff --git a/rest-api-templates/ari_resource.h.mustache b/rest-api-templates/ari_resource.h.mustache
index f28e832d1..5e06af734 100644
--- a/rest-api-templates/ari_resource.h.mustache
+++ b/rest-api-templates/ari_resource.h.mustache
@@ -109,6 +109,17 @@ int ast_ari_websocket_{{c_name}}_{{c_nickname}}_init(void);
* {{{notes}}}
{{/notes}}
*
+ * \return Nothing
+ */
+void ast_ari_websocket_{{c_name}}_{{c_nickname}}_dtor(void);
+
+/*!
+ * \brief {{summary}}
+{{#notes}}
+ *
+ * {{{notes}}}
+{{/notes}}
+ *
* \param ser HTTP TCP/TLS Server Session
* \param headers HTTP headers
* \param args Swagger parameters