<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8659">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjproject_bundled: timer: Clean up usage of timer heap<br><br>Added a new pj_timer_entry_reset function that resets a timer_entry<br>for re-use.<br><br>Changed direct settings of timer_entry fields to use<br>pj_timer_entry_init and pj_timer_entry_reset.<br><br>Fixed issues where timers were being rescheduled incorrectly.<br><br>Change-Id: I5b624bfbc5c1429117484b9b24567293002148e6<br>---<br>A third-party/pjproject/patches/0080-timer-Clean-up-usage-of-timer-heap.patch<br>1 file changed, 434 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/third-party/pjproject/patches/0080-timer-Clean-up-usage-of-timer-heap.patch b/third-party/pjproject/patches/0080-timer-Clean-up-usage-of-timer-heap.patch<br>new file mode 100644<br>index 0000000..6c139ba<br>--- /dev/null<br>+++ b/third-party/pjproject/patches/0080-timer-Clean-up-usage-of-timer-heap.patch<br>@@ -0,0 +1,434 @@<br>+From 853005378de2ffecee7774e095d8cbfbfa0ab706 Mon Sep 17 00:00:00 2001<br>+From: George Joseph <gjoseph@digium.com><br>+Date: Tue, 2 Jan 2018 06:36:46 -0700<br>+Subject: [PATCH] timer: Clean up usage of timer heap<br>+<br>+Added a new pj_timer_entry_reset function that resets a timer_entry<br>+for re-use.<br>+<br>+Changed direct settings of timer_entry fields to use<br>+pj_timer_entry_init and pj_timer_entry_reset.<br>+<br>+Fixed issues where timers were being rescheduled incorrectly.<br>+---<br>+ pjlib/include/pj/timer.h             | 14 ++++++++++++++<br>+ pjlib/src/pj/ssl_sock_ossl.c         |  8 +++++---<br>+ pjlib/src/pj/timer.c                 | 12 ++++++++++++<br>+ pjnath/src/pjnath/ice_session.c      |  9 ++++++++-<br>+ pjnath/src/pjnath/nat_detect.c       |  2 ++<br>+ pjnath/src/pjnath/stun_sock.c        |  2 +-<br>+ pjnath/src/pjnath/stun_transaction.c | 10 +++++-----<br>+ pjnath/src/pjnath/turn_session.c     |  3 +++<br>+ pjnath/src/pjnath/turn_sock.c        |  1 +<br>+ pjnath/src/pjturn-srv/allocation.c   |  4 ++--<br>+ pjnath/src/pjturn-srv/listener_tcp.c |  2 +-<br>+ pjsip/src/pjsip-simple/evsub.c       |  6 +++---<br>+ pjsip/src/pjsip/sip_endpoint.c       |  4 +++-<br>+ pjsip/src/pjsip/sip_transaction.c    |  9 +++------<br>+ pjsip/src/pjsip/sip_transport.c      |  3 +--<br>+ 15 files changed, 64 insertions(+), 25 deletions(-)<br>+<br>+diff --git a/pjlib/include/pj/timer.h b/pjlib/include/pj/timer.h<br>+index df6155a81..90fc8ac85 100644<br>+--- a/pjlib/include/pj/timer.h<br>++++ b/pjlib/include/pj/timer.h<br>+@@ -212,6 +212,20 @@ PJ_DECL(pj_timer_entry*) pj_timer_entry_init( pj_timer_entry *entry,<br>+                                               void *user_data,<br>+                                               pj_timer_heap_callback *cb );<br>+ <br>++/**<br>++ * Reset a timer entry. Application should call this function before reusing<br>++ * the timer entry.<br>++ *<br>++ * @param entry     The timer entry to be initialized.<br>++ * @param id        Arbitrary ID assigned by the user/owner of this entry.<br>++ *                  Applications can use this ID to distinguish multiple<br>++ *                  timer entries that share the same callback and user_data.<br>++ *<br>++ * @return          The timer entry itself.<br>++ */<br>++PJ_DECL(pj_timer_entry*) pj_timer_entry_reset( pj_timer_entry *entry,<br>++                                             int id);<br>++<br>+ /**<br>+  * Queries whether a timer entry is currently running.<br>+  *<br>+diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c<br>+index 969cc1420..ead1a8fbb 100644<br>+--- a/pjlib/src/pj/ssl_sock_ossl.c<br>++++ b/pjlib/src/pj/ssl_sock_ossl.c<br>+@@ -291,6 +291,7 @@ struct pj_ssl_cert_t<br>+ static write_data_t* alloc_send_data(pj_ssl_sock_t *ssock, pj_size_t len);<br>+ static void free_send_data(pj_ssl_sock_t *ssock, write_data_t *wdata);<br>+ static pj_status_t flush_delayed_send(pj_ssl_sock_t *ssock);<br>++static void on_timer(pj_timer_heap_t *th, struct pj_timer_entry *te);<br>+ <br>+ /*<br>+  *******************************************************************<br>+@@ -1621,7 +1622,8 @@ static pj_bool_t on_handshake_complete(pj_ssl_sock_t *ssock,<br>+                pj_timer_heap_cancel(ssock->param.timer_heap,<br>+                                          &ssock->timer);<br>+              }<br>+-           ssock->timer.id = TIMER_CLOSE;<br>++<br>++               pj_timer_entry_reset(&ssock->timer, TIMER_CLOSE);<br>+             pj_time_val_normalize(&interval);<br>+                if (pj_timer_heap_schedule(ssock->param.timer_heap, <br>+                                         &ssock->timer, &interval) != 0)<br>+@@ -2387,7 +2389,7 @@ static pj_bool_t asock_on_accept_complete (pj_activesock_t *asock,<br>+     ssock->param.timeout.msec != 0))<br>+     {<br>+         pj_assert(ssock->timer.id == TIMER_NONE);<br>+-        ssock->timer.id = TIMER_HANDSHAKE_TIMEOUT;<br>++       pj_timer_entry_reset(&ssock->timer, TIMER_HANDSHAKE_TIMEOUT);<br>+         status = pj_timer_heap_schedule(ssock->param.timer_heap, <br>+                                         &ssock->timer,<br>+                                        &ssock->param.timeout);<br>+@@ -3405,7 +3407,7 @@ PJ_DEF(pj_status_t) pj_ssl_sock_start_connect( pj_ssl_sock_t *ssock,<br>+  ssock->param.timeout.msec != 0))<br>+     {<br>+         pj_assert(ssock->timer.id == TIMER_NONE);<br>+-        ssock->timer.id = TIMER_HANDSHAKE_TIMEOUT;<br>++       pj_timer_entry_reset(&ssock->timer, TIMER_HANDSHAKE_TIMEOUT);<br>+         status = pj_timer_heap_schedule(ssock->param.timer_heap,<br>+                                  &ssock->timer,<br>+                                        &ssock->param.timeout);<br>+diff --git a/pjlib/src/pj/timer.c b/pjlib/src/pj/timer.c<br>+index 90a95e37b..13126116f 100644<br>+--- a/pjlib/src/pj/timer.c<br>++++ b/pjlib/src/pj/timer.c<br>+@@ -472,6 +472,18 @@ PJ_DEF(pj_timer_entry*) pj_timer_entry_init( pj_timer_entry *entry,<br>+     return entry;<br>+ }<br>+ <br>++PJ_DEF(pj_timer_entry*) pj_timer_entry_reset( pj_timer_entry *entry,<br>++                                             int id)<br>++{<br>++    entry->id = id;<br>++    entry->_grp_lock = NULL;<br>++    entry->_timer_id = -1;<br>++    entry->_timer_value = (pj_time_val){0, 0};<br>++<br>++    return entry;<br>++}<br>++<br>++<br>+ PJ_DEF(pj_bool_t) pj_timer_entry_running( pj_timer_entry *entry )<br>+ {<br>+     return (entry->_timer_id >= 1);<br>+diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c<br>+index 63a0d1c9c..6d0e6abc9 100644<br>+--- a/pjnath/src/pjnath/ice_session.c<br>++++ b/pjnath/src/pjnath/ice_session.c<br>+@@ -1246,6 +1246,7 @@ done:<br>+                  ice->comp_cnt;<br>+       pj_time_val_normalize(&delay);<br>+ <br>++      pj_timer_entry_reset(&ice->timer, TIMER_KEEP_ALIVE);<br>+  pj_timer_heap_schedule_w_grp_lock(ice->stun_cfg.timer_heap,<br>+                                         &ice->timer, &delay,<br>+                                      TIMER_KEEP_ALIVE,<br>+@@ -1276,7 +1277,7 @@ static void on_ice_complete(pj_ice_sess *ice, pj_status_t status)<br>+        /* Call callback */<br>+  if (ice->cb.on_ice_complete) {<br>+        pj_time_val delay = {0, 0};<br>+-<br>++     pj_timer_entry_reset(&ice->timer, TIMER_COMPLETION_CALLBACK);<br>+         pj_timer_heap_schedule_w_grp_lock(ice->stun_cfg.timer_heap,<br>+                                         &ice->timer, &delay,<br>+                                              TIMER_COMPLETION_CALLBACK,<br>+@@ -1507,6 +1508,7 @@ static pj_bool_t on_check_complete(pj_ice_sess *ice,<br>+                    delay.sec = 0;<br>+               delay.msec = ice->opt.controlled_agent_want_nom_timeout;<br>+                  pj_time_val_normalize(&delay);<br>++                  pj_timer_entry_reset(&ice->timer, TIMER_CONTROLLED_WAIT_NOM);<br>+ <br>+                     pj_timer_heap_schedule_w_grp_lock(<br>+                                       ice->stun_cfg.timer_heap,<br>+@@ -1597,6 +1599,7 @@ static pj_bool_t on_check_complete(pj_ice_sess *ice,<br>+    delay.sec = 0;<br>+       delay.msec = ice->opt.nominated_check_delay;<br>+      pj_time_val_normalize(&delay);<br>++        pj_timer_entry_reset(&ice->timer, TIMER_START_NOMINATED_CHECK);<br>+ <br>+     pj_timer_heap_schedule_w_grp_lock(ice->stun_cfg.timer_heap,<br>+                                         &ice->timer, &delay,<br>+@@ -1929,6 +1932,8 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,<br>+       pj_time_val timeout = {0, PJ_ICE_TA_VAL};<br>+ <br>+        pj_time_val_normalize(&timeout);<br>++        pj_timer_entry_reset(&ice->timer, PJ_TRUE);<br>++<br>+       pj_timer_heap_schedule_w_grp_lock(th, te, &timeout, PJ_TRUE,<br>+                                       ice->grp_lock);<br>+     }<br>+@@ -1986,6 +1991,7 @@ static void start_nominated_check(pj_ice_sess *ice)<br>+                                    &ice->clist.timer, PJ_FALSE);<br>+ <br>+     delay.sec = delay.msec = 0;<br>++    pj_timer_entry_reset(&ice->timer, PJ_TRUE);<br>+     status = pj_timer_heap_schedule_w_grp_lock(ice->stun_cfg.timer_heap,<br>+                                                &ice->clist.timer, &delay,<br>+                                                PJ_TRUE,<br>+@@ -2125,6 +2131,7 @@ PJ_DEF(pj_status_t) pj_ice_sess_start_check(pj_ice_sess *ice)<br>+      * return start_periodic_check(ice->stun_cfg.timer_heap, &clist->timer);<br>+      */<br>+     delay.sec = delay.msec = 0;<br>++    pj_timer_entry_reset(&ice->timer, PJ_TRUE);<br>+     status = pj_timer_heap_schedule_w_grp_lock(ice->stun_cfg.timer_heap,<br>+                                                &clist->timer, &delay,<br>+                                                PJ_TRUE, ice->grp_lock);<br>+diff --git a/pjnath/src/pjnath/nat_detect.c b/pjnath/src/pjnath/nat_detect.c<br>+index 8a2408374..7bb364798 100644<br>+--- a/pjnath/src/pjnath/nat_detect.c<br>++++ b/pjnath/src/pjnath/nat_detect.c<br>+@@ -414,6 +414,7 @@ static void end_session(nat_detect_session *sess,<br>+     delay.msec = 0;<br>+ <br>+     sess->timer.id = TIMER_DESTROY;<br>++    pj_timer_entry_init(&sess->timer, TIMER_DESTROY, sess, &on_sess_timer);<br>+     pj_timer_heap_schedule(sess->timer_heap, &sess->timer, &delay);<br>+ }<br>+ <br>+@@ -933,6 +934,7 @@ static void on_sess_timer(pj_timer_heap_t *th,<br>+ <br>+      if (next_timer) {<br>+        pj_time_val delay = {0, TEST_INTERVAL};<br>++     pj_timer_entry_reset(te, TIMER_TEST);<br>+        pj_timer_heap_schedule(th, te, &delay);<br>+      } else {<br>+         te->id = 0;<br>+diff --git a/pjnath/src/pjnath/stun_sock.c b/pjnath/src/pjnath/stun_sock.c<br>+index 6028e0c47..3aab27a1d 100644<br>+--- a/pjnath/src/pjnath/stun_sock.c<br>++++ b/pjnath/src/pjnath/stun_sock.c<br>+@@ -864,7 +864,7 @@ static void start_ka_timer(pj_stun_sock *stun_sock)<br>+ <br>+        delay.sec = stun_sock->ka_interval;<br>+       delay.msec = 0;<br>+-<br>++ pj_timer_entry_reset(&stun_sock->ka_timer, PJ_TRUE);<br>+  pj_timer_heap_schedule_w_grp_lock(stun_sock->stun_cfg.timer_heap,<br>+                                           &stun_sock->ka_timer,<br>+                                         &delay, PJ_TRUE,<br>+diff --git a/pjnath/src/pjnath/stun_transaction.c b/pjnath/src/pjnath/stun_transaction.c<br>+index 28f623005..ad87b7b6c 100644<br>+--- a/pjnath/src/pjnath/stun_transaction.c<br>++++ b/pjnath/src/pjnath/stun_transaction.c<br>+@@ -86,11 +86,8 @@ PJ_DEF(pj_status_t) pj_stun_client_tsx_create(pj_stun_config *cfg,<br>+     tsx->grp_lock = grp_lock;<br>+     pj_memcpy(&tsx->cb, cb, sizeof(*cb));<br>+ <br>+-    tsx->retransmit_timer.cb = &retransmit_timer_callback;<br>+-    tsx->retransmit_timer.user_data = tsx;<br>+-<br>+-    tsx->destroy_timer.cb = &destroy_timer_callback;<br>+-    tsx->destroy_timer.user_data = tsx;<br>++    pj_timer_entry_init(&tsx->retransmit_timer, 0, tsx, &retransmit_timer_callback);<br>++    pj_timer_entry_init(&tsx->destroy_timer, 0, tsx, &destroy_timer_callback);<br>+ <br>+     pj_ansi_snprintf(tsx->obj_name, sizeof(tsx->obj_name), "utsx%p", tsx);<br>+ <br>+@@ -120,6 +117,7 @@ PJ_DEF(pj_status_t) pj_stun_client_tsx_schedule_destroy(<br>+     pj_timer_heap_cancel_if_active(tsx->timer_heap, &tsx->retransmit_timer,<br>+                                    TIMER_INACTIVE);<br>+ <br>++    pj_timer_entry_reset(&tsx->destroy_timer, TIMER_ACTIVE);<br>+     status = pj_timer_heap_schedule_w_grp_lock(tsx->timer_heap,<br>+                                                &tsx->destroy_timer, delay,<br>+                                                TIMER_ACTIVE, tsx->grp_lock);<br>+@@ -237,6 +235,7 @@ static pj_status_t tsx_transmit_msg(pj_stun_client_tsx *tsx,<br>+   * cancel it (as opposed to when schedule_timer() failed we cannot<br>+    * cancel transmission).<br>+      */;<br>++        pj_timer_entry_reset(&tsx->retransmit_timer, TIMER_ACTIVE);<br>+   status = pj_timer_heap_schedule_w_grp_lock(tsx->timer_heap,<br>+                                                  &tsx->retransmit_timer,<br>+                                               &tsx->retransmit_time,<br>+@@ -315,6 +314,7 @@ PJ_DEF(pj_status_t) pj_stun_client_tsx_send_msg(pj_stun_client_tsx *tsx,<br>+       * cancel it (as opposed to when schedule_timer() failed we cannot<br>+    * cancel transmission).<br>+      */;<br>++        pj_timer_entry_reset(&tsx->retransmit_timer, TIMER_ACTIVE);<br>+   status = pj_timer_heap_schedule_w_grp_lock(tsx->timer_heap,<br>+                                                  &tsx->retransmit_timer,<br>+                                               &tsx->retransmit_time,<br>+diff --git a/pjnath/src/pjnath/turn_session.c b/pjnath/src/pjnath/turn_session.c<br>+index bbea027f3..e4685e625 100644<br>+--- a/pjnath/src/pjnath/turn_session.c<br>++++ b/pjnath/src/pjnath/turn_session.c<br>+@@ -431,6 +431,7 @@ static void sess_shutdown(pj_turn_session *sess,<br>+ <br>+         pj_timer_heap_cancel_if_active(sess->timer_heap, &sess->timer,<br>+                                    TIMER_NONE);<br>++ pj_timer_entry_reset(&sess->timer, TIMER_DESTROY);<br>+    pj_timer_heap_schedule_w_grp_lock(sess->timer_heap, &sess->timer,<br>+                                    &delay, TIMER_DESTROY,<br>+                                           sess->grp_lock);<br>+@@ -1434,6 +1435,7 @@ static void on_allocate_success(pj_turn_session *sess,<br>+         timeout.sec = sess->ka_interval;<br>+  timeout.msec = 0;<br>+ <br>++       pj_timer_entry_reset(&sess->timer, TIMER_KEEP_ALIVE);<br>+         pj_timer_heap_schedule_w_grp_lock(sess->timer_heap, &sess->timer,<br>+                                    &timeout, TIMER_KEEP_ALIVE,<br>+                                      sess->grp_lock);<br>+@@ -2080,6 +2082,7 @@ static void on_timer_event(pj_timer_heap_t *th, pj_timer_entry *e)<br>+         delay.sec = sess->ka_interval;<br>+            delay.msec = 0;<br>+ <br>++         pj_timer_entry_reset(&sess->timer, TIMER_KEEP_ALIVE);<br>+         pj_timer_heap_schedule_w_grp_lock(sess->timer_heap, &sess->timer,<br>+                                            &delay, TIMER_KEEP_ALIVE,<br>+                                        sess->grp_lock);<br>+diff --git a/pjnath/src/pjnath/turn_sock.c b/pjnath/src/pjnath/turn_sock.c<br>+index a30ab5153..507858048 100644<br>+--- a/pjnath/src/pjnath/turn_sock.c<br>++++ b/pjnath/src/pjnath/turn_sock.c<br>+@@ -928,6 +928,7 @@ static void turn_on_state(pj_turn_session *sess,<br>+ <br>+    pj_timer_heap_cancel_if_active(turn_sock->cfg.timer_heap,<br>+                                        &turn_sock->timer, 0);<br>++        pj_timer_entry_reset(&turn_sock->timer, TIMER_DESTROY);<br>+       pj_timer_heap_schedule_w_grp_lock(turn_sock->cfg.timer_heap,<br>+                                        &turn_sock->timer,<br>+                                    &delay, TIMER_DESTROY,<br>+diff --git a/pjnath/src/pjturn-srv/allocation.c b/pjnath/src/pjturn-srv/allocation.c<br>+index 6c9c9ce11..88533926b 100644<br>+--- a/pjnath/src/pjturn-srv/allocation.c<br>++++ b/pjnath/src/pjturn-srv/allocation.c<br>+@@ -513,7 +513,7 @@ static void alloc_shutdown(pj_turn_allocation *alloc)<br>+      */<br>+ <br>+     /* Schedule destroy timer */<br>+-    alloc->relay.timer.id = TIMER_ID_DESTROY;<br>++    pj_timer_entry_reset(&alloc->relay.timer, TIMER_ID_DESTROY);<br>+     pj_timer_heap_schedule(alloc->server->core.timer_heap,<br>+                         &alloc->relay.timer, &destroy_delay);<br>+ }<br>+@@ -538,7 +538,7 @@ static pj_status_t resched_timeout(pj_turn_allocation *alloc)<br>+     delay.sec = alloc->relay.lifetime;<br>+     delay.msec = 0;<br>+ <br>+-    alloc->relay.timer.id = TIMER_ID_TIMEOUT;<br>++    pj_timer_entry_reset(&alloc->relay.timer, TIMER_ID_TIMEOUT);<br>+     status = pj_timer_heap_schedule(alloc->server->core.timer_heap,<br>+                                 &alloc->relay.timer, &delay);<br>+     if (status != PJ_SUCCESS) {<br>+diff --git a/pjnath/src/pjturn-srv/listener_tcp.c b/pjnath/src/pjturn-srv/listener_tcp.c<br>+index 796ed471b..4a9550c2e 100644<br>+--- a/pjnath/src/pjturn-srv/listener_tcp.c<br>++++ b/pjnath/src/pjturn-srv/listener_tcp.c<br>+@@ -475,7 +475,7 @@ static void tcp_dec_ref(pj_turn_transport *tp,<br>+ <br>+     if (tcp->ref_cnt == 0 && tcp->timer.id == TIMER_NONE) {<br>+       pj_time_val delay = { SHUTDOWN_DELAY, 0 };<br>+-  tcp->timer.id = TIMER_DESTROY;<br>++   pj_timer_entry_reset(&tcp->timer, TIMER_DESTROY);<br>+     pj_timer_heap_schedule(tcp->base.listener->server->core.timer_heap,<br>+                                &tcp->timer, &delay);<br>+     }<br>+diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c<br>+index eb666654f..7748853d2 100644<br>+--- a/pjsip/src/pjsip-simple/evsub.c<br>++++ b/pjsip/src/pjsip-simple/evsub.c<br>+@@ -518,6 +518,7 @@ static void set_timer( pjsip_evsub *sub, int timer_id,<br>+       timeout.sec = seconds;<br>+       timeout.msec = 0;<br>+ <br>++       pj_timer_entry_reset(&sub->timer, timer_id);<br>+  pj_timer_heap_schedule_w_grp_lock(<br>+                       pjsip_endpt_get_timer_heap(sub->endpt),<br>+                           &sub->timer, &timeout, timer_id, sub->grp_lock);<br>+@@ -655,7 +656,7 @@ static void on_timer( pj_timer_heap_t *timer_heap,<br>+     /* If this timer entry has just been rescheduled or cancelled<br>+      * while waiting for dialog mutex, just return (see #1885 scenario 1).<br>+      */<br>+-    if (pj_timer_entry_running(entry) || entry->id == TIMER_TYPE_NONE) {<br>++    if (entry->id == TIMER_TYPE_NONE) {<br>+       pjsip_dlg_dec_lock(sub->dlg);<br>+     return;<br>+     }<br>+@@ -786,8 +787,7 @@ static pj_status_t evsub_create( pjsip_dialog *dlg,<br>+                     pjsip_hdr_clone(sub->pool, pkg->pkg_accept);<br>+     pj_list_init(&sub->sub_hdr_list);<br>+ <br>+-    sub->timer.user_data = sub;<br>+-    sub->timer.cb = &on_timer;<br>++    pj_timer_entry_init(&sub->timer, 0, sub, &on_timer);<br>+ <br>+     /* Set name. */<br>+     pj_ansi_snprintf(sub->obj_name, PJ_ARRAY_SIZE(sub->obj_name),<br>+diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c<br>+index d810781d5..5c98a5bf6 100644<br>+--- a/pjsip/src/pjsip/sip_endpoint.c<br>++++ b/pjsip/src/pjsip/sip_endpoint.c<br>+@@ -788,6 +788,7 @@ PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_dbg(pjsip_endpoint *endpt,<br>+ {<br>+     PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer(entry=%p, delay=%u.%u)",<br>+                        entry, delay->sec, delay->msec));<br>++    pj_timer_entry_reset(entry, entry->id);<br>+     return pj_timer_heap_schedule_dbg(endpt->timer_heap, entry, delay,<br>+                                       src_file, src_line);<br>+ }<br>+@@ -798,6 +799,7 @@ PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt,<br>+ {<br>+     PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer(entry=%p, delay=%u.%u)",<br>+                      entry, delay->sec, delay->msec));<br>++    pj_timer_entry_reset(entry, entry->id);<br>+     return pj_timer_heap_schedule( endpt->timer_heap, entry, delay );<br>+ }<br>+ #endif<br>+@@ -809,7 +811,7 @@ PJ_DEF(void) pjsip_endpt_cancel_timer( pjsip_endpoint *endpt,<br>+                                   pj_timer_entry *entry )<br>+ {<br>+     PJ_LOG(6, (THIS_FILE, "pjsip_endpt_cancel_timer(entry=%p)", entry));<br>+-    pj_timer_heap_cancel( endpt->timer_heap, entry );<br>++    pj_timer_heap_cancel_if_active( endpt->timer_heap, entry, 0 );<br>+ }<br>+ <br>+ /*<br>+diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c<br>+index d52b12a72..5236e63f7 100644<br>+--- a/pjsip/src/pjsip/sip_transaction.c<br>++++ b/pjsip/src/pjsip/sip_transaction.c<br>+@@ -978,6 +978,7 @@ static pj_status_t tsx_schedule_timer(pjsip_transaction *tsx,<br>+     pj_status_t status;<br>+ <br>+     pj_assert(active_id != 0);<br>++    pj_timer_entry_reset(entry, active_id);<br>+     status = pj_timer_heap_schedule_w_grp_lock(timer_heap, entry,<br>+                                                delay, active_id,<br>+                                                tsx->grp_lock);<br>+@@ -1019,12 +1020,8 @@ static pj_status_t tsx_create( pjsip_module *tsx_user,<br>+     pj_memcpy(pool->obj_name, tsx->obj_name, sizeof(pool->obj_name));<br>+ <br>+     tsx->handle_200resp = 1;<br>+-    tsx->retransmit_timer.id = TIMER_INACTIVE;<br>+-    tsx->retransmit_timer.user_data = tsx;<br>+-    tsx->retransmit_timer.cb = &tsx_timer_callback;<br>+-    tsx->timeout_timer.id = TIMER_INACTIVE;<br>+-    tsx->timeout_timer.user_data = tsx;<br>+-    tsx->timeout_timer.cb = &tsx_timer_callback;<br>++    pj_timer_entry_init(&tsx->retransmit_timer, TIMER_INACTIVE, tsx, &tsx_timer_callback);<br>++    pj_timer_entry_init(&tsx->timeout_timer, TIMER_INACTIVE, tsx, &tsx_timer_callback);<br>+     <br>+     if (grp_lock) {<br>+   tsx->grp_lock = grp_lock;<br>+diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c<br>+index 3d27d5d71..834babeae 100644<br>+--- a/pjsip/src/pjsip/sip_transport.c<br>++++ b/pjsip/src/pjsip/sip_transport.c<br>+@@ -1092,8 +1092,7 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,<br>+     /* Init. */<br>+     tp->tpmgr = mgr;<br>+     pj_bzero(&tp->idle_timer, sizeof(tp->idle_timer));<br>+-    tp->idle_timer.user_data = tp;<br>+-    tp->idle_timer.cb = &transport_idle_callback;<br>++    pj_timer_entry_init(&tp->idle_timer, 0, tp, &transport_idle_callback);<br>+ <br>+     /* <br>+      * Register to hash table (see Trac ticket #42).<br>+-- <br>+2.14.3<br>+<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8659">change 8659</a>. To unsubscribe, 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/8659"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I5b624bfbc5c1429117484b9b24567293002148e6 </div>
<div style="display:none"> Gerrit-Change-Number: 8659 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>