res_pjsip.c: Add check that timer actually got scheduled.
authorRichard Mudgett <rmudgett@digium.com>
Wed, 6 Jan 2016 01:08:24 +0000 (19:08 -0600)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 14 Jun 2016 21:46:49 +0000 (16:46 -0500)
Change-Id: Iabaa2e5dccf0762c258101ea0eb1487cf6959ad1

res/res_pjsip.c

index 8fc3c53..9944702 100644 (file)
@@ -3406,7 +3406,7 @@ static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint,
                ast_debug(2, "%p: Set timer to %d msec\n", req_wrapper, timeout);
 
                pj_timer_entry_init(req_wrapper->timeout_timer, TIMEOUT_TIMER2,
-                       req_wrapper, &send_request_timer_callback);
+                       req_wrapper, send_request_timer_callback);
 
                pj_timer_heap_cancel_if_active(pjsip_endpt_get_timer_heap(endpt),
                        req_wrapper->timeout_timer, TIMER_INACTIVE);
@@ -3415,8 +3415,18 @@ static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint,
                 * timer callback is executed.
                 */
                ao2_ref(req_wrapper, +1);
-               pj_timer_heap_schedule(pjsip_endpt_get_timer_heap(endpt),
+               ret_val = pj_timer_heap_schedule(pjsip_endpt_get_timer_heap(endpt),
                        req_wrapper->timeout_timer, &timeout_timer_val);
+               if (ret_val != PJ_SUCCESS) {
+                       ao2_unlock(req_wrapper);
+                       ast_log(LOG_ERROR,
+                               "Failed to set timer.  Not sending %.*s request to endpoint %s.\n",
+                               (int) pj_strlen(&tdata->msg->line.req.method.name),
+                               pj_strbuf(&tdata->msg->line.req.method.name),
+                               endpoint ? ast_sorcery_object_get_id(endpoint) : "<unknown>");
+                       ao2_t_ref(req_wrapper, -2, "Drop timer and routine ref");
+                       return ret_val;
+               }
 
                req_wrapper->timeout_timer->id = TIMEOUT_TIMER2;
        } else {