[asterisk-commits] mmichelson: branch 13 r430608 - /branches/13/res/res_pjsip_outbound_publish.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 14 14:27:22 CST 2015
Author: mmichelson
Date: Wed Jan 14 14:27:18 2015
New Revision: 430608
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=430608
Log:
Prevent slow graceful shutdown when outbound publications never started.
The code was missing the case for explicitly destroying an outbound publication
when Asterisk had never actually published anything. The result was that Asterisk
would hang for a while on a graceful shutdown.
With this change, the case is taken into account, and on a graceful shutdown, these
publications are destroyed without the need to actually send a PUBLISH request.
ASTERISK-24655 #close
Reported by Kevin Harwell
Review: https://reviewboard.asterisk.org/r/4325
Modified:
branches/13/res/res_pjsip_outbound_publish.c
Modified: branches/13/res/res_pjsip_outbound_publish.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip_outbound_publish.c?view=diff&rev=430608&r1=430607&r2=430608
==============================================================================
--- branches/13/res/res_pjsip_outbound_publish.c (original)
+++ branches/13/res/res_pjsip_outbound_publish.c Wed Jan 14 14:27:18 2015
@@ -662,25 +662,40 @@
}
}
+static int explicit_publish_destroy(void *data)
+{
+ struct ast_sip_outbound_publish_client *client = data;
+
+ pjsip_publishc_destroy(client->client);
+ ao2_ref(client, -1);
+
+ return 0;
+}
+
/*! \brief Helper function which cancels and un-publishes a no longer used client */
static int cancel_and_unpublish(struct ast_sip_outbound_publish_client *client)
{
+ struct ast_sip_event_publisher_handler *handler;
SCOPED_AO2LOCK(lock, client);
- /* If this publish client is currently publishing stop and terminate any refresh timer */
- if (client->started) {
- struct ast_sip_event_publisher_handler *handler = find_publisher_handler_for_event_name(client->publish->event);
-
- if (handler) {
- handler->stop_publishing(client);
- }
-
- client->started = 0;
- if (ast_sip_push_task(NULL, cancel_refresh_timer_task, ao2_bump(client))) {
- ast_log(LOG_WARNING, "Could not stop refresh timer on outbound publish '%s'\n",
- ast_sorcery_object_get_id(client->publish));
- ao2_ref(client, -1);
- }
+ if (!client->started) {
+ /* If the client was never started, there's nothing to unpublish, so just
+ * destroy the publication and remove its reference to the client.
+ */
+ ast_sip_push_task(NULL, explicit_publish_destroy, client);
+ return 0;
+ }
+
+ handler = find_publisher_handler_for_event_name(client->publish->event);
+ if (handler) {
+ handler->stop_publishing(client);
+ }
+
+ client->started = 0;
+ if (ast_sip_push_task(NULL, cancel_refresh_timer_task, ao2_bump(client))) {
+ ast_log(LOG_WARNING, "Could not stop refresh timer on outbound publish '%s'\n",
+ ast_sorcery_object_get_id(client->publish));
+ ao2_ref(client, -1);
}
/* If nothing is being sent right now send the unpublish - the destroy will happen in the subsequent callback */
More information about the asterisk-commits
mailing list