[asterisk-commits] res ari events: Fix shutdown ref leak. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 19 17:06:51 CDT 2015


Mark Michelson has submitted this change and it was merged.

Change subject: res_ari_events: Fix shutdown ref leak.
......................................................................


res_ari_events: Fix shutdown ref leak.

ASTERISK-25308 #close
Reported by: Joshua Colp

Change-Id: I592785bf70ff4b63d00e535b482f40da8e82a082
---
M res/ari/resource_events.c
M res/ari/resource_events.h
M res/res_ari_events.c
M rest-api-templates/ari_resource.h.mustache
4 files changed, 31 insertions(+), 7 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Ashley Sanders: Looks good to me, but someone else must approve



diff --git a/res/ari/resource_events.c b/res/ari/resource_events.c
index f1342b7..deb7f9c 100644
--- a/res/ari/resource_events.c
+++ b/res/ari/resource_events.c
@@ -103,12 +103,12 @@
 		        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 @@
 	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 bc763eb..aa1e3df 100644
--- a/res/ari/resource_events.h
+++ b/res/ari/resource_events.h
@@ -60,6 +60,13 @@
 /*!
  * \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 bf33aea..4b2b151 100644
--- a/res/res_ari_events.c
+++ b/res/res_ari_events.c
@@ -462,6 +462,7 @@
 	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 f28e832..5e06af7 100644
--- a/rest-api-templates/ari_resource.h.mustache
+++ b/rest-api-templates/ari_resource.h.mustache
@@ -109,6 +109,17 @@
  * {{{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

-- 
To view, visit https://gerrit.asterisk.org/1114
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I592785bf70ff4b63d00e535b482f40da8e82a082
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Ashley Sanders <asanders at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list