<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15134">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_outbound_registration.c: Use our own scheduler and other stuff<br><br>* Instead of using the pjproject timer heap, we now use our own<br> pjsip_scheduler. This allows us to more easily debug and allows us to<br> see times in "pjsip show/list registrations" as well as being able to<br> see the registrations in "pjsip show scheduled_tasks".<br><br>* Added the last registration time, registration interval, and the next<br> registration time to the CLI output.<br><br>* Removed calls to pjsip_regc_info() except where absolutely necessary.<br> Most of the calls were just to get the server and client URIs for log<br> messages so we now just save them on the client_state object when we<br> create it.<br><br>* Added log messages where needed and updated most of the existong ones<br> to include the registration object name at the start of the message.<br><br>Change-Id: I4534a0fc78c7cb69f23b7b449dda9748c90daca2<br>---<br>M res/res_pjsip_outbound_registration.c<br>1 file changed, 165 insertions(+), 121 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c</span><br><span>index 2c58986..5be38eb 100644</span><br><span>--- a/res/res_pjsip_outbound_registration.c</span><br><span>+++ b/res/res_pjsip_outbound_registration.c</span><br><span>@@ -359,7 +359,7 @@</span><br><span> */</span><br><span> pjsip_tx_data *last_tdata;</span><br><span> /*! \brief Timer entry for retrying on temporal responses */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_timer_entry timer;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_sip_sched_task *sched_task;</span><br><span> /*! \brief Optional line parameter placed into Contact */</span><br><span> char line[LINE_PARAMETER_SIZE];</span><br><span> /*! \brief Current number of retries */</span><br><span>@@ -392,6 +392,12 @@</span><br><span> char *transport_name;</span><br><span> /*! \brief The name of the registration sorcery object */</span><br><span> char *registration_name;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \brief Server URI */</span><br><span style="color: hsl(120, 100%, 40%);">+ char *server_uri;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \brief Client URI */</span><br><span style="color: hsl(120, 100%, 40%);">+ char *client_uri;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \brief Contact URI */</span><br><span style="color: hsl(120, 100%, 40%);">+ char *contact_uri;</span><br><span> };</span><br><span> </span><br><span> /*! \brief Outbound registration state information (persists for lifetime that registration should exist) */</span><br><span>@@ -530,8 +536,8 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(3, "Determined relationship to outbound registration '%s' based on line '%s', using configured endpoint '%s'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sorcery_object_get_id(state->registration), state->client_state->line, state->registration->endpoint);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "%s: Line '%s', using configured endpoint '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->registration_name, state->client_state->line, state->registration->endpoint);</span><br><span> </span><br><span> return ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", state->registration->endpoint);</span><br><span> }</span><br><span>@@ -543,10 +549,10 @@</span><br><span> /*! \brief Helper function which cancels the timer on a client */</span><br><span> static void cancel_registration(struct sip_outbound_registration_client_state *client_state)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- if (pj_timer_heap_cancel_if_active(pjsip_endpt_get_timer_heap(ast_sip_get_pjsip_endpoint()),</span><br><span style="color: hsl(0, 100%, 40%);">- &client_state->timer, client_state->timer.id)) {</span><br><span style="color: hsl(0, 100%, 40%);">- /* The timer was successfully cancelled, drop the refcount of client_state */</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(client_state, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (client_state->sched_task) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sip_sched_task_cancel(client_state->sched_task);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(client_state->sched_task);</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->sched_task = NULL;</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -564,6 +570,8 @@</span><br><span> callback_invoked = ast_threadstorage_get(®ister_callback_invoked, sizeof(int));</span><br><span> if (!callback_invoked) {</span><br><span> pjsip_tx_data_dec_ref(tdata);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "%s: Failed to get threadstorage for registration to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name, client_state->server_uri, client_state->client_uri);</span><br><span> return PJ_ENOMEM;</span><br><span> }</span><br><span> *callback_invoked = 0;</span><br><span>@@ -593,6 +601,8 @@</span><br><span> * drop the references we just added</span><br><span> */</span><br><span> if ((status != PJ_SUCCESS) && !(*callback_invoked)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "%s: Failed send registration to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name, client_state->server_uri, client_state->client_uri);</span><br><span> pjsip_tx_data_dec_ref(tdata);</span><br><span> ao2_ref(client_state, -1);</span><br><span> return status;</span><br><span>@@ -655,7 +665,7 @@</span><br><span> /*! \brief Callback function for registering */</span><br><span> static int handle_client_registration(void *data)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- RAII_VAR(struct sip_outbound_registration_client_state *, client_state, data, ao2_cleanup);</span><br><span style="color: hsl(120, 100%, 40%);">+ struct sip_outbound_registration_client_state *client_state = data;</span><br><span> pjsip_tx_data *tdata;</span><br><span> </span><br><span> if (set_outbound_initial_authentication_credentials(client_state->client, &client_state->outbound_auths)) {</span><br><span>@@ -663,19 +673,14 @@</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (client_state->status == SIP_REGISTRATION_STOPPED</span><br><span style="color: hsl(0, 100%, 40%);">- || pjsip_regc_register(client_state->client, PJ_FALSE, &tdata) != PJ_SUCCESS) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (client_state->status == SIP_REGISTRATION_STOPPED) {</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (DEBUG_ATLEAST(1)) {</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_info info;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_get_info(client_state->client, &info);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_DEBUG, "Outbound REGISTER attempt %u to '%.*s' with client '%.*s'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- client_state->retries + 1,</span><br><span style="color: hsl(0, 100%, 40%);">- (int) info.server_uri.slen, info.server_uri.ptr,</span><br><span style="color: hsl(0, 100%, 40%);">- (int) info.client_uri.slen, info.client_uri.ptr);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (pjsip_regc_register(client_state->client, PJ_FALSE, &tdata) != PJ_SUCCESS) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "%s: Failed to create registration to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name, client_state->server_uri, client_state->client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span> }</span><br><span> </span><br><span> if (!add_configured_supported_headers(client_state, tdata)) {</span><br><span>@@ -688,44 +693,23 @@</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*! \brief Timer callback function, used just for registrations */</span><br><span style="color: hsl(0, 100%, 40%);">-static void sip_outbound_registration_timer_cb(pj_timer_heap_t *timer_heap, struct pj_timer_entry *entry)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct sip_outbound_registration_client_state *client_state = entry->user_data;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- entry->id = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * Transfer client_state reference to serializer task so the</span><br><span style="color: hsl(0, 100%, 40%);">- * nominal path will not dec the client_state ref in this</span><br><span style="color: hsl(0, 100%, 40%);">- * pjproject callback thread.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_sip_push_task(client_state->serializer, handle_client_registration, client_state)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Scheduled outbound registration could not be executed.\n");</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(client_state, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /*! \brief Helper function which sets up the timer to re-register in a specific amount of time */</span><br><span style="color: hsl(0, 100%, 40%);">-static void schedule_registration(struct sip_outbound_registration_client_state *client_state, unsigned int seconds)</span><br><span style="color: hsl(120, 100%, 40%);">+static void schedule_registration(struct sip_outbound_registration_client_state *client_state, unsigned int ms)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_time_val delay = { .sec = seconds, };</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_info info;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Scheduling outbound registration to server '%s' from client '%s' in %d ms\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name, client_state->server_uri, client_state->client_uri, ms);</span><br><span> </span><br><span> cancel_registration(client_state);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_get_info(client_state->client, &info);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Scheduling outbound registration to server '%.*s' from client '%.*s' in %d seconds\n",</span><br><span style="color: hsl(0, 100%, 40%);">- (int) info.server_uri.slen, info.server_uri.ptr,</span><br><span style="color: hsl(0, 100%, 40%);">- (int) info.client_uri.slen, info.client_uri.ptr,</span><br><span style="color: hsl(0, 100%, 40%);">- seconds);</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->sched_task = ast_sip_schedule_task(client_state->serializer,</span><br><span style="color: hsl(120, 100%, 40%);">+ ms, handle_client_registration, ast_taskprocessor_name(client_state->serializer),</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state,</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_SIP_SCHED_TASK_ONESHOT | AST_SIP_SCHED_TASK_DATA_AO2);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(client_state, +1);</span><br><span style="color: hsl(0, 100%, 40%);">- if (pjsip_endpt_schedule_timer(ast_sip_get_pjsip_endpoint(), &client_state->timer, &delay) != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Failed to schedule registration to server '%.*s' from client '%.*s'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- (int) info.server_uri.slen, info.server_uri.ptr,</span><br><span style="color: hsl(0, 100%, 40%);">- (int) info.client_uri.slen, info.client_uri.ptr);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(client_state, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!client_state->sched_task) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Failed to schedule registration to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name, client_state->server_uri, client_state->client_uri);</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -762,18 +746,18 @@</span><br><span> {</span><br><span> struct sip_outbound_registration_client_state *client_state = data;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- cancel_registration(client_state);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> if (client_state->client) {</span><br><span> pjsip_regc_info info;</span><br><span> pjsip_tx_data *tdata;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* We need to get the live state to test "is_busy" */</span><br><span> pjsip_regc_get_info(client_state->client, &info);</span><br><span> </span><br><span> if (info.is_busy == PJ_TRUE) {</span><br><span> /* If a client transaction is in progress we defer until it is complete */</span><br><span> ast_debug(1,</span><br><span style="color: hsl(0, 100%, 40%);">- "Registration transaction is busy with server '%.*s' from client '%.*s'.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ "%s: Registration transaction is busy with server '%.*s' from client '%.*s'.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name,</span><br><span> (int) info.server_uri.slen, info.server_uri.ptr,</span><br><span> (int) info.client_uri.slen, info.client_uri.ptr);</span><br><span> client_state->destroy = 1;</span><br><span>@@ -786,10 +770,11 @@</span><br><span> break;</span><br><span> case SIP_REGISTRATION_REGISTERED:</span><br><span> ast_debug(1,</span><br><span style="color: hsl(0, 100%, 40%);">- "Trying to unregister with server '%.*s' from client '%.*s' before destruction.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ "%s: Trying to unregister with server '%.*s' from client '%.*s' before destruction.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name,</span><br><span> (int) info.server_uri.slen, info.server_uri.ptr,</span><br><span> (int) info.client_uri.slen, info.client_uri.ptr);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+ cancel_registration(client_state);</span><br><span> update_client_state_status(client_state, SIP_REGISTRATION_STOPPING);</span><br><span> client_state->destroy = 1;</span><br><span> if (pjsip_regc_unregister(client_state->client, &tdata) == PJ_SUCCESS</span><br><span>@@ -800,8 +785,10 @@</span><br><span> }</span><br><span> break;</span><br><span> case SIP_REGISTRATION_REJECTED_TEMPORARY:</span><br><span style="color: hsl(0, 100%, 40%);">- case SIP_REGISTRATION_REJECTED_PERMANENT:</span><br><span> case SIP_REGISTRATION_STOPPING:</span><br><span style="color: hsl(120, 100%, 40%);">+ cancel_registration(client_state);</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ case SIP_REGISTRATION_REJECTED_PERMANENT:</span><br><span> case SIP_REGISTRATION_STOPPED:</span><br><span> break;</span><br><span> }</span><br><span>@@ -812,6 +799,7 @@</span><br><span> </span><br><span> update_client_state_status(client_state, SIP_REGISTRATION_STOPPED);</span><br><span> ast_sip_auth_vector_destroy(&client_state->outbound_auths);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ao2_ref(client_state, -1);</span><br><span> </span><br><span> return 0;</span><br><span>@@ -869,20 +857,21 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static void schedule_retry(struct registration_response *response, unsigned int interval,</span><br><span style="color: hsl(0, 100%, 40%);">- const char *server_uri, const char *client_uri)</span><br><span style="color: hsl(120, 100%, 40%);">+static void schedule_retry(struct registration_response *response, unsigned int interval)</span><br><span> {</span><br><span> update_client_state_status(response->client_state, SIP_REGISTRATION_REJECTED_TEMPORARY);</span><br><span style="color: hsl(0, 100%, 40%);">- schedule_registration(response->client_state, interval);</span><br><span style="color: hsl(120, 100%, 40%);">+ schedule_registration(response->client_state, interval * 1000);</span><br><span> </span><br><span> if (response->rdata) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Temporal response '%d' received from '%s' on "</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Temporal response '%d' received from '%s' on "</span><br><span> "registration attempt to '%s', retrying in '%u'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- response->code, server_uri, client_uri, interval);</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->code, response->client_state->server_uri, response->client_state->client_uri, interval);</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "No response received from '%s' on "</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: No response received from '%s' on "</span><br><span> "registration attempt to '%s', retrying in '%u'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- server_uri, client_uri, interval);</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->server_uri, response->client_state->client_uri, interval);</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -895,15 +884,9 @@</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (DEBUG_ATLEAST(1)) {</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_info info;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_get_info(state->client_state->client, &info);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_DEBUG,</span><br><span style="color: hsl(0, 100%, 40%);">- "Outbound registration transport to server '%.*s' from client '%.*s' shutdown\n",</span><br><span style="color: hsl(0, 100%, 40%);">- (int) info.server_uri.slen, info.server_uri.ptr,</span><br><span style="color: hsl(0, 100%, 40%);">- (int) info.client_uri.slen, info.client_uri.ptr);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1,</span><br><span style="color: hsl(120, 100%, 40%);">+ "%s: Outbound registration transport to server '%s' from client '%s' shutdown\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->registration_name, state->client_state->server_uri, state->client_state->client_uri);</span><br><span> </span><br><span> cancel_registration(state->client_state);</span><br><span> </span><br><span>@@ -1045,21 +1028,15 @@</span><br><span> static int handle_registration_response(void *data)</span><br><span> {</span><br><span> struct registration_response *response = data;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_info info;</span><br><span style="color: hsl(0, 100%, 40%);">- char server_uri[PJSIP_MAX_URL_SIZE];</span><br><span style="color: hsl(0, 100%, 40%);">- char client_uri[PJSIP_MAX_URL_SIZE];</span><br><span> </span><br><span> if (response->client_state->status == SIP_REGISTRATION_STOPPED) {</span><br><span> ao2_ref(response, -1);</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_get_info(response->client_state->client, &info);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_pj_str(server_uri, &info.server_uri, sizeof(server_uri));</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_pj_str(client_uri, &info.client_uri, sizeof(client_uri));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Processing REGISTER response %d from server '%s' for client '%s'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- response->code, server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Processing REGISTER response %d from server '%s' for client '%s' with expiration '%d'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->code, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri, response->expiration);</span><br><span> </span><br><span> if (response->code == 408 || response->code == 503) {</span><br><span> if ((ast_sip_failover_request(response->old_request))) {</span><br><span>@@ -1081,8 +1058,9 @@</span><br><span> if (!ast_sip_create_request_with_auth(&response->client_state->outbound_auths,</span><br><span> response->rdata, response->old_request, &tdata)) {</span><br><span> response->client_state->auth_attempted = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Sending authenticated REGISTER to server '%s' from client '%s'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Sending authenticated REGISTER to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri);</span><br><span> pjsip_tx_data_add_ref(tdata);</span><br><span> res = registration_client_send(response->client_state, tdata);</span><br><span> </span><br><span>@@ -1096,8 +1074,9 @@</span><br><span> return 0;</span><br><span> }</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Failed to create authenticated REGISTER request to server '%s' from client '%s'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Failed to create authenticated REGISTER request to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri);</span><br><span> }</span><br><span> /* Otherwise, fall through so the failure is processed appropriately */</span><br><span> }</span><br><span>@@ -1110,13 +1089,15 @@</span><br><span> int next_registration_round;</span><br><span> </span><br><span> /* If the registration went fine simply reschedule registration for the future */</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Outbound registration to '%s' with client '%s' successful\n", server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Outbound registration to '%s' with client '%s' successful\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri);</span><br><span> update_client_state_status(response->client_state, SIP_REGISTRATION_REGISTERED);</span><br><span> response->client_state->retries = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- next_registration_round = response->expiration - REREGISTER_BUFFER_TIME;</span><br><span style="color: hsl(120, 100%, 40%);">+ next_registration_round = (response->expiration - REREGISTER_BUFFER_TIME) * 1000;</span><br><span> if (next_registration_round < 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- /* Re-register immediately. */</span><br><span style="color: hsl(0, 100%, 40%);">- next_registration_round = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Re-register no sooner than the buffer time. */</span><br><span style="color: hsl(120, 100%, 40%);">+ next_registration_round = REREGISTER_BUFFER_TIME * 1000;</span><br><span> }</span><br><span> schedule_registration(response->client_state, next_registration_round);</span><br><span> </span><br><span>@@ -1124,7 +1105,9 @@</span><br><span> registration_transport_monitor_setup(response->rdata->tp_info.transport,</span><br><span> response->client_state->registration_name);</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Outbound unregistration to '%s' with client '%s' successful\n", server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Outbound unregistration to '%s' with client '%s' successful\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri);</span><br><span> update_client_state_status(response->client_state, SIP_REGISTRATION_UNREGISTERED);</span><br><span> ast_sip_transport_monitor_unregister(response->rdata->tp_info.transport,</span><br><span> registration_transport_shutdown_cb, response->client_state->registration_name,</span><br><span>@@ -1136,18 +1119,19 @@</span><br><span> /* We need to deal with the pending destruction instead. */</span><br><span> } else if (response->retry_after) {</span><br><span> /* If we have been instructed to retry after a period of time, schedule it as such */</span><br><span style="color: hsl(0, 100%, 40%);">- schedule_retry(response, response->retry_after, server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ schedule_retry(response, response->retry_after);</span><br><span> } else if (response->client_state->retry_interval</span><br><span> && sip_outbound_registration_is_temporal(response->code, response->client_state)) {</span><br><span> if (response->client_state->retries == response->client_state->max_retries) {</span><br><span> /* If we received enough temporal responses to exceed our maximum give up permanently */</span><br><span> update_client_state_status(response->client_state, SIP_REGISTRATION_REJECTED_PERMANENT);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Maximum retries reached when attempting outbound registration to '%s' with client '%s', stopping registration attempt\n",</span><br><span style="color: hsl(0, 100%, 40%);">- server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Maximum retries reached when attempting outbound registration to '%s' with client '%s', stopping registration attempt\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri);</span><br><span> } else {</span><br><span> /* On the other hand if we can still try some more do so */</span><br><span> response->client_state->retries++;</span><br><span style="color: hsl(0, 100%, 40%);">- schedule_retry(response, response->client_state->retry_interval, server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ schedule_retry(response, response->client_state->retry_interval);</span><br><span> }</span><br><span> } else {</span><br><span> if (response->code == 403</span><br><span>@@ -1156,30 +1140,34 @@</span><br><span> /* A forbidden response retry interval is configured and there are retries remaining */</span><br><span> update_client_state_status(response->client_state, SIP_REGISTRATION_REJECTED_TEMPORARY);</span><br><span> response->client_state->retries++;</span><br><span style="color: hsl(0, 100%, 40%);">- schedule_registration(response->client_state, response->client_state->forbidden_retry_interval);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "403 Forbidden fatal response received from '%s' on registration attempt to '%s', retrying in '%u' seconds\n",</span><br><span style="color: hsl(0, 100%, 40%);">- server_uri, client_uri, response->client_state->forbidden_retry_interval);</span><br><span style="color: hsl(120, 100%, 40%);">+ schedule_registration(response->client_state, response->client_state->forbidden_retry_interval * 1000);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: 403 Forbidden fatal response received from '%s' on registration attempt to '%s', retrying in '%u' seconds\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri, response->client_state->forbidden_retry_interval);</span><br><span> } else if (response->client_state->fatal_retry_interval</span><br><span> && response->client_state->retries < response->client_state->max_retries) {</span><br><span> /* Some kind of fatal failure response received, so retry according to configured interval */</span><br><span> update_client_state_status(response->client_state, SIP_REGISTRATION_REJECTED_TEMPORARY);</span><br><span> response->client_state->retries++;</span><br><span style="color: hsl(0, 100%, 40%);">- schedule_registration(response->client_state, response->client_state->fatal_retry_interval);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "'%d' fatal response received from '%s' on registration attempt to '%s', retrying in '%u' seconds\n",</span><br><span style="color: hsl(0, 100%, 40%);">- response->code, server_uri, client_uri, response->client_state->fatal_retry_interval);</span><br><span style="color: hsl(120, 100%, 40%);">+ schedule_registration(response->client_state, response->client_state->fatal_retry_interval * 1000);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: '%d' fatal response received from '%s' on registration attempt to '%s', retrying in '%u' seconds\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->code, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri, response->client_state->fatal_retry_interval);</span><br><span> } else {</span><br><span> /* Finally if there's no hope of registering give up */</span><br><span> update_client_state_status(response->client_state, SIP_REGISTRATION_REJECTED_PERMANENT);</span><br><span> if (response->rdata) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Fatal response '%d' received from '%s' on registration attempt to '%s', stopping outbound registration\n",</span><br><span style="color: hsl(0, 100%, 40%);">- response->code, server_uri, client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Fatal response '%d' received from '%s' on registration attempt to '%s', stopping outbound registration\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->code, response->client_state->server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->client_uri);</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Fatal registration attempt to '%s', stopping outbound registration\n", client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Fatal registration attempt to '%s', stopping outbound registration\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ response->client_state->registration_name, response->client_state->client_uri);</span><br><span> }</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_system_publish_registry("PJSIP", client_uri, server_uri,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_system_publish_registry("PJSIP", response->client_state->client_uri, response->client_state->server_uri,</span><br><span> sip_outbound_registration_status_str(response->client_state->status), NULL);</span><br><span> </span><br><span> if (response->client_state->destroy) {</span><br><span>@@ -1220,8 +1208,10 @@</span><br><span> */</span><br><span> response->client_state = client_state;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Received REGISTER response %d(%.*s)\n",</span><br><span style="color: hsl(0, 100%, 40%);">- param->code, (int) param->reason.slen, param->reason.ptr);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Received REGISTER response %d(%.*s) from '%s': Expires: %d\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name,</span><br><span style="color: hsl(120, 100%, 40%);">+ param->code, (int) param->reason.slen, param->reason.ptr,</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->server_uri, param->expiration);</span><br><span> </span><br><span> if (param->rdata) {</span><br><span> struct pjsip_retry_after_hdr *retry_after;</span><br><span>@@ -1256,7 +1246,8 @@</span><br><span> * pjproject callback thread.</span><br><span> */</span><br><span> if (ast_sip_push_task(client_state->serializer, handle_registration_response, response)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Failed to pass incoming registration response to threadpool\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Failed to pass incoming registration response to threadpool\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name);</span><br><span> ao2_cleanup(response);</span><br><span> }</span><br><span> }</span><br><span>@@ -1266,7 +1257,8 @@</span><br><span> {</span><br><span> struct sip_outbound_registration_state *state = obj;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(3, "Destroying registration state for registration to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "%s: Destroying registration state for registration to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->registration_name,</span><br><span> state->registration ? state->registration->server_uri : "",</span><br><span> state->registration ? state->registration->client_uri : "");</span><br><span> ao2_cleanup(state->registration);</span><br><span>@@ -1277,7 +1269,8 @@</span><br><span> ao2_ref(state->client_state, -1);</span><br><span> } else if (ast_sip_push_task(state->client_state->serializer,</span><br><span> handle_client_state_destruction, state->client_state)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Failed to pass outbound registration client destruction to threadpool\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Failed to pass outbound registration client destruction to threadpool\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->registration_name);</span><br><span> ao2_ref(state->client_state, -1);</span><br><span> }</span><br><span> }</span><br><span>@@ -1287,6 +1280,9 @@</span><br><span> {</span><br><span> struct sip_outbound_registration_client_state *client_state = obj;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "%s: Destroying registration client state\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ client_state->registration_name);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_statsd_log_string("PJSIP.registrations.count", AST_STATSD_GAUGE, "-1", 1.0);</span><br><span> ast_statsd_log_string_va("PJSIP.registrations.state.%s", AST_STATSD_GAUGE, "-1", 1.0,</span><br><span> sip_outbound_registration_status_str(client_state->status));</span><br><span>@@ -1294,6 +1290,9 @@</span><br><span> ast_taskprocessor_unreference(client_state->serializer);</span><br><span> ast_free(client_state->transport_name);</span><br><span> ast_free(client_state->registration_name);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(client_state->server_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(client_state->client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(client_state->contact_uri);</span><br><span> if (client_state->last_tdata) {</span><br><span> pjsip_tx_data_dec_ref(client_state->last_tdata);</span><br><span> }</span><br><span>@@ -1317,8 +1316,6 @@</span><br><span> }</span><br><span> </span><br><span> state->client_state->status = SIP_REGISTRATION_UNREGISTERED;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_timer_entry_init(&state->client_state->timer, 0, state->client_state,</span><br><span style="color: hsl(0, 100%, 40%);">- sip_outbound_registration_timer_cb);</span><br><span> state->client_state->transport_name = ast_strdup(registration->transport);</span><br><span> state->client_state->registration_name =</span><br><span> ast_strdup(ast_sorcery_object_get_id(registration));</span><br><span>@@ -1674,6 +1671,7 @@</span><br><span> }</span><br><span> </span><br><span> pj_cstr(&server_uri, registration->server_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->server_uri = ast_strdup(registration->server_uri);</span><br><span> </span><br><span> if (sip_dialog_create_contact(pjsip_regc_get_pool(state->client_state->client),</span><br><span> &contact_uri, S_OR(registration->contact_user, "s"), &server_uri, &selector,</span><br><span>@@ -1681,15 +1679,19 @@</span><br><span> ast_sip_tpselector_unref(&selector);</span><br><span> return -1;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_pj_str2(&state->client_state->contact_uri, &contact_uri);</span><br><span> </span><br><span> ast_sip_tpselector_unref(&selector);</span><br><span> </span><br><span> pj_cstr(&client_uri, registration->client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->client_uri = ast_strdup(registration->client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (pjsip_regc_init(state->client_state->client, &server_uri, &client_uri,</span><br><span> &client_uri, 1, &contact_uri, registration->expiration) != PJ_SUCCESS) {</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span>@@ -1700,6 +1702,10 @@</span><br><span> struct sip_outbound_registration *registration = ao2_bump(state->registration);</span><br><span> size_t i;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Performing register to server '%s' from client '%s' Expiration: %d\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->registration_name,</span><br><span style="color: hsl(120, 100%, 40%);">+ state->registration->server_uri, state->registration->client_uri, registration->expiration);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Just in case the client state is being reused for this registration, free the auth information */</span><br><span> ast_sip_auth_vector_destroy(&state->client_state->outbound_auths);</span><br><span> </span><br><span>@@ -1722,7 +1728,7 @@</span><br><span> </span><br><span> pjsip_regc_update_expires(state->client_state->client, registration->expiration);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- schedule_registration(state->client_state, (ast_random() % 10) + 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ schedule_registration(state->client_state, ((ast_random() % 10) + 1) * 1000);</span><br><span> </span><br><span> ao2_ref(registration, -1);</span><br><span> ao2_ref(state, -1);</span><br><span>@@ -1851,10 +1857,9 @@</span><br><span> struct sip_outbound_registration_state *state = obj;</span><br><span> struct pjsip_regc *client = state->client_state->client;</span><br><span> pjsip_tx_data *tdata;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_info info;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_get_info(client, &info);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Unregistering contacts with server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Unregistering contacts with server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->registration_name,</span><br><span> state->registration->server_uri, state->registration->client_uri);</span><br><span> </span><br><span> cancel_registration(state->client_state);</span><br><span>@@ -1882,6 +1887,11 @@</span><br><span> static int queue_register(struct sip_outbound_registration_state *state)</span><br><span> {</span><br><span> ao2_ref(state, +1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "%s: Queueing register to server '%s' from client '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ state->client_state->registration_name,</span><br><span style="color: hsl(120, 100%, 40%);">+ state->registration->server_uri, state->registration->client_uri);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_sip_push_task(state->client_state->serializer, sip_outbound_registration_perform, state)) {</span><br><span> ao2_ref(state, -1);</span><br><span> return -1;</span><br><span>@@ -2135,7 +2145,7 @@</span><br><span> ast_sip_sorcery_object_to_ami(ami->registration, &buf);</span><br><span> </span><br><span> if ((state = get_state(ast_sorcery_object_get_id(ami->registration)))) {</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_info info;</span><br><span style="color: hsl(120, 100%, 40%);">+ int next_reg = 0;</span><br><span> </span><br><span> if (state->client_state->status == SIP_REGISTRATION_REGISTERED) {</span><br><span> ++ami->registered;</span><br><span>@@ -2146,8 +2156,12 @@</span><br><span> ast_str_append(&buf, 0, "Status: %s\r\n",</span><br><span> sip_outbound_registration_status_str(state->client_state->status));</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_regc_get_info(state->client_state->client, &info);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&buf, 0, "NextReg: %d\r\n", info.next_reg);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (state->client_state->status == SIP_REGISTRATION_REGISTERED && state->client_state->sched_task) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sip_sched_task_get_times2(state->client_state->sched_task, NULL, NULL, NULL, NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ &next_reg, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&buf, 0, "NextReg: %d\r\n", next_reg / 1000);</span><br><span> ao2_ref(state, -1);</span><br><span> }</span><br><span> </span><br><span>@@ -2252,22 +2266,46 @@</span><br><span> ast_assert(context->output_buffer != NULL);</span><br><span> </span><br><span> ast_str_append(&context->output_buffer, 0,</span><br><span style="color: hsl(0, 100%, 40%);">- " <Registration/ServerURI..............................> <Auth..........> <Status.......>\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ " <Registration/ServerURI..............................> <Auth..........> <Status.......>");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&context->output_buffer, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ " <Last Reg..> <Intvl> <Next Start.....secs>\n"</span><br><span style="color: hsl(120, 100%, 40%);">+ "==============================================");</span><br><span> </span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#define TIME_FORMAT "%a %T"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int cli_print_body(void *obj, void *arg, int flags)</span><br><span> {</span><br><span> struct sip_outbound_registration *registration = obj;</span><br><span> struct ast_sip_cli_context *context = arg;</span><br><span> const char *id = ast_sorcery_object_get_id(registration);</span><br><span> struct sip_outbound_registration_state *state = get_state(id);</span><br><span style="color: hsl(120, 100%, 40%);">+ int next_run_ms = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct timeval next = { 0, 0 };</span><br><span style="color: hsl(120, 100%, 40%);">+ struct timeval last = { 0, 0 };</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_tm tm;</span><br><span style="color: hsl(120, 100%, 40%);">+ char next_start[32] = "";</span><br><span style="color: hsl(120, 100%, 40%);">+ char last_start[32] = "";</span><br><span style="color: hsl(120, 100%, 40%);">+ int interval;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #define REGISTRATION_URI_FIELD_LEN 53</span><br><span> </span><br><span> ast_assert(context->output_buffer != NULL);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&context->output_buffer, 0, " %-s/%-*.*s %-16s %-16s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ if (state->client_state->sched_task) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sip_sched_task_get_times2(state->client_state->sched_task, &last, NULL, NULL, &interval,</span><br><span style="color: hsl(120, 100%, 40%);">+ &next_run_ms, &next);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_localtime(&last, &tm, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_strftime(last_start, sizeof(last_start), TIME_FORMAT, &tm);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_localtime(&next, &tm, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_strftime(next_start, sizeof(next_start), TIME_FORMAT, &tm);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&context->output_buffer, 0, " %-s/%-*.*s %-16s %-16s",</span><br><span> id,</span><br><span> (int) (REGISTRATION_URI_FIELD_LEN - strlen(id)),</span><br><span> (int) (REGISTRATION_URI_FIELD_LEN - strlen(id)),</span><br><span>@@ -2275,9 +2313,15 @@</span><br><span> AST_VECTOR_SIZE(®istration->outbound_auths)</span><br><span> ? AST_VECTOR_GET(®istration->outbound_auths, 0)</span><br><span> : "n/a",</span><br><span style="color: hsl(0, 100%, 40%);">- (state ? sip_outbound_registration_status_str(state->client_state->status) : "Unregistered"));</span><br><span style="color: hsl(120, 100%, 40%);">+ (state ? sip_outbound_registration_status_str(state->client_state->status) : "Unregistered")</span><br><span style="color: hsl(120, 100%, 40%);">+ );</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&context->output_buffer, 0, " %-12s %7d %-12s %8d\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ last_start, interval / 1000, next_start, next_run_ms / 1000);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ao2_cleanup(state);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (context->show_details</span><br><span> || (context->show_details_only_level_0 && context->indent_level == 0)) {</span><br><span> ast_str_append(&context->output_buffer, 0, "\n");</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15134">change 15134</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/15134"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I4534a0fc78c7cb69f23b7b449dda9748c90daca2 </div>
<div style="display:none"> Gerrit-Change-Number: 15134 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>