Changeset 5971
- Timestamp:
- Apr 23, 2019 8:42:45 AM (6 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/timer.h
r4567 r5971 253 253 * @param ht The timer heap. 254 254 * @param entry The entry to be registered. 255 * @param delay The interval to expire. 255 256 * @param id_val The value to be set to the "id" field of the timer entry 256 257 * once the timer is scheduled. 257 * @param delay The interval to expire.258 258 * @param grp_lock The group lock. 259 259 * -
pjproject/trunk/pjlib/src/pj/timer.c
r5934 r5971 503 503 504 504 /* Prevent same entry from being scheduled more than once */ 505 PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP);505 //PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP); 506 506 507 507 #if PJ_TIMER_DEBUG … … 513 513 514 514 lock_timer_heap(ht); 515 516 /* Prevent same entry from being scheduled more than once */ 517 if (pj_timer_entry_running(entry)) { 518 unlock_timer_heap(ht); 519 PJ_LOG(3,(THIS_FILE, "Bug! Rescheduling outstanding entry (%p)", 520 entry)); 521 return PJ_EINVALIDOP; 522 } 523 515 524 status = schedule_entry(ht, entry, &expires); 516 525 if (status == PJ_SUCCESS) { -
pjproject/trunk/pjsip/include/pjsip/sip_endpoint.h
r5397 r5971 139 139 const pj_time_val *max_timeout, 140 140 unsigned *count); 141 141 142 /** 142 143 * Schedule timer to endpoint's timer heap. Application must poll the endpoint … … 165 166 pj_timer_entry *entry, 166 167 const pj_time_val *delay ); 168 #endif 169 170 /** 171 * Schedule timer to endpoint's timer heap with group lock. Application must 172 * poll the endpoint periodically (by calling #pjsip_endpt_handle_events) to 173 * ensure that the timer events are handled in timely manner. When the 174 * timeout for the timer has elapsed, the callback specified in the entry 175 * argument will be called. This function, like all other endpoint functions, 176 * is thread safe. 177 * 178 * @param endpt The endpoint. 179 * @param entry The timer entry. 180 * @param delay The relative delay of the timer. 181 * @param id_val The value to be set to the "id" field of the timer entry 182 * once the timer is scheduled. 183 * @param grp_lock The group lock. 184 * @return PJ_OK (zero) if successfull. 185 */ 186 #if PJ_TIMER_DEBUG 187 #define pjsip_endpt_schedule_timer_w_grp_lock(ept,ent,d,id,gl) \ 188 pjsip_endpt_schedule_timer_w_grp_lock_dbg(ept,ent,d,id,gl,\ 189 __FILE__, __LINE__) 190 191 PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock_dbg( 192 pjsip_endpoint *endpt, 193 pj_timer_entry *entry, 194 const pj_time_val *delay, 195 int id_val, 196 pj_grp_lock_t *grp_lock, 197 const char *src_file, 198 int src_line); 199 #else 200 PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock( 201 pjsip_endpoint *endpt, 202 pj_timer_entry *entry, 203 const pj_time_val *delay, 204 int id_val, 205 pj_grp_lock_t *grp_lock ); 167 206 #endif 168 207 -
pjproject/trunk/pjsip/include/pjsip/sip_transport.h
r5884 r5971 811 811 pj_atomic_t *ref_cnt; /**< Reference counter. */ 812 812 pj_lock_t *lock; /**< Lock object. */ 813 pj_grp_lock_t *grp_lock; /**< Group lock for sync with 814 ioqueue and timer. */ 813 815 pj_bool_t tracing; /**< Tracing enabled? */ 814 816 pj_bool_t is_shutdown; /**< Being shutdown? */ -
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r5668 r5971 804 804 805 805 /* 806 * Schedule timer with group lock. 807 */ 808 #if PJ_TIMER_DEBUG 809 PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock_dbg( 810 pjsip_endpoint *endpt, 811 pj_timer_entry *entry, 812 const pj_time_val *delay, 813 int id_val, 814 pj_grp_lock_t *grp_lock, 815 const char *src_file, 816 int src_line) 817 { 818 PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer_w_grp_lock" 819 "(entry=%p, delay=%u.%u, grp_lock=%p)", 820 entry, delay->sec, delay->msec, grp_lock)); 821 return pj_timer_heap_schedule_w_grp_lock_dbg(endpt->timer_heap, entry, 822 delay, id_val, grp_lock, 823 src_file, src_line); 824 } 825 #else 826 PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock( 827 pjsip_endpoint *endpt, 828 pj_timer_entry *entry, 829 const pj_time_val *delay, 830 int id_val, 831 pj_grp_lock_t *grp_lock ) 832 { 833 PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer_w_grp_lock" 834 "(entry=%p, delay=%u.%u, grp_lock=%p)", 835 entry, delay->sec, delay->msec, grp_lock)); 836 return pj_timer_heap_schedule_w_grp_lock( endpt->timer_heap, entry, 837 delay, id_val, grp_lock ); 838 } 839 #endif 840 841 /* 806 842 * Cancel the previously registered timer. 807 843 */ -
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r5909 r5971 1013 1013 PJ_UNUSED_ARG(timer_heap); 1014 1014 1015 if (entry->id == PJ_FALSE) 1016 return; 1017 1015 1018 entry->id = PJ_FALSE; 1016 1019 pjsip_transport_destroy(tp); … … 1049 1052 1050 1053 PJ_ASSERT_RETURN(tp != NULL, PJ_EINVAL); 1054 1055 /* Add ref transport group lock, if any */ 1056 if (tp->grp_lock) 1057 pj_grp_lock_add_ref(tp->grp_lock); 1051 1058 1052 1059 /* Cache some vars for checking transport validity later */ … … 1064 1071 { 1065 1072 if (tp->idle_timer.id != PJ_FALSE) { 1073 tp->idle_timer.id = PJ_FALSE; 1066 1074 pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer); 1067 tp->idle_timer.id = PJ_FALSE;1068 1075 } 1069 1076 } … … 1115 1122 } 1116 1123 1117 pj_assert(tp->idle_timer.id == 0); 1118 tp->idle_timer.id = PJ_TRUE; 1119 pjsip_endpt_schedule_timer(tp->tpmgr->endpt, &tp->idle_timer, 1120 &delay); 1124 /* Avoid double timer entry scheduling */ 1125 if (pj_timer_entry_running(&tp->idle_timer)) 1126 pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer); 1127 1128 pjsip_endpt_schedule_timer_w_grp_lock(tp->tpmgr->endpt, 1129 &tp->idle_timer, 1130 &delay, 1131 PJ_TRUE, 1132 tp->grp_lock); 1121 1133 } 1122 1134 pj_lock_release(tpmgr->lock); 1123 1135 } 1136 1137 /* Dec ref transport group lock, if any */ 1138 if (tp->grp_lock) 1139 pj_grp_lock_dec_ref(tp->grp_lock); 1124 1140 1125 1141 return PJ_SUCCESS; … … 1169 1185 pj_hash_set(tp->pool, mgr->table, &tp->key, key_len, hval, tp); 1170 1186 1187 /* Add ref transport group lock, if any */ 1188 if (tp->grp_lock) 1189 pj_grp_lock_add_ref(tp->grp_lock); 1190 1171 1191 pj_lock_release(mgr->lock); 1172 1192 … … 1200 1220 //pj_assert(tp->idle_timer.id == PJ_FALSE); 1201 1221 if (tp->idle_timer.id != PJ_FALSE) { 1222 tp->idle_timer.id = PJ_FALSE; 1202 1223 pjsip_endpt_cancel_timer(mgr->endpt, &tp->idle_timer); 1203 tp->idle_timer.id = PJ_FALSE;1204 1224 } 1205 1225 … … 1226 1246 pj_lock_release(mgr->lock); 1227 1247 pj_lock_release(tp->lock); 1248 1249 /* Dec ref transport group lock, if any */ 1250 if (tp->grp_lock) 1251 pj_grp_lock_dec_ref(tp->grp_lock); 1228 1252 1229 1253 /* Destroy. */ -
pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c
r5870 r5971 693 693 pj_grp_lock_add_handler(tcp->grp_lock, pool, tcp, &tcp_on_destroy); 694 694 695 tcp->base.grp_lock = tcp->grp_lock; 696 695 697 /* Create active socket */ 696 698 pj_activesock_cfg_default(&asock_cfg); … … 747 749 748 750 on_error: 749 tcp_destroy(&tcp->base, status); 751 if (tcp->grp_lock && pj_grp_lock_get_ref(tcp->grp_lock)) 752 tcp_destroy(&tcp->base, status); 753 else 754 tcp_on_destroy(tcp); 755 750 756 return status; 751 757 } … … 868 874 pj_grp_lock_dec_ref(grp_lock); 869 875 /* Transport may have been deleted at this point */ 870 } else {871 tcp_on_destroy(tcp);872 876 } 873 877 -
pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
r5936 r5971 164 164 const pj_str_t *remote_name, 165 165 struct tls_transport **p_tls); 166 167 168 /* Clean up TLS resources */ 169 static void tls_on_destroy(void *arg); 166 170 167 171 … … 894 898 895 899 on_error: 896 tls_destroy(&tls->base, status); 900 if (tls->grp_lock && pj_grp_lock_get_ref(tls->grp_lock)) 901 tls_destroy(&tls->base, status); 902 else 903 tls_on_destroy(tls); 904 897 905 return status; 898 906 } … … 1049 1057 pj_grp_lock_dec_ref(grp_lock); 1050 1058 /* Transport may have been deleted at this point */ 1051 } else {1052 tls_on_destroy(tls);1053 1059 } 1054 1060 … … 1236 1242 1237 1243 /* Set up the group lock */ 1238 tls->grp_lock = glock;1244 tls->grp_lock = tls->base.grp_lock = glock; 1239 1245 pj_grp_lock_add_ref(tls->grp_lock); 1240 1246 pj_grp_lock_add_handler(tls->grp_lock, pool, tls, &tls_on_destroy); -
pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
r5911 r5971 692 692 pj_grp_lock_add_handler(tp->grp_lock, tp->base.pool, tp, 693 693 &udp_on_destroy); 694 695 tp->base.grp_lock = tp->grp_lock; 694 696 } 695 697
Note: See TracChangeset
for help on using the changeset viewer.