Changeset 5519
- Timestamp:
- Jan 11, 2017 3:35:17 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
r5311 r5519 77 77 int is_closing; 78 78 pj_bool_t is_paused; 79 int read_loop_spin; 79 80 80 81 /* Group lock to be used by UDP transport and ioqueue key */ … … 130 131 pj_status_t status; 131 132 133 ++tp->read_loop_spin; 134 132 135 /* Don't do anything if transport is closing. */ 133 136 if (tp->is_closing) { 134 137 tp->is_closing++; 135 return;138 goto on_return; 136 139 } 137 140 138 141 /* Don't do anything if transport is being paused. */ 139 142 if (tp->is_paused) 140 return;143 goto on_return; 141 144 142 145 /* … … 228 231 */ 229 232 if (tp->is_paused) 230 return;233 break; 231 234 232 235 /* Read next packet. */ … … 244 247 245 248 } else if (status == PJ_EPENDING) { 249 break; 250 251 } else if (status == PJ_ECANCELLED) { 252 /* Socket is closing, quit loop */ 246 253 break; 247 254 … … 277 284 } 278 285 } 286 287 on_return: 288 --tp->read_loop_spin; 279 289 } 280 290 … … 624 634 return PJ_SUCCESS; 625 635 626 /* Create group lock */ 627 status = pj_grp_lock_create(tp->base.pool, NULL, &tp->grp_lock); 628 if (status != PJ_SUCCESS) 629 return status; 630 631 pj_grp_lock_add_ref(tp->grp_lock); 632 pj_grp_lock_add_handler(tp->grp_lock, tp->base.pool, tp, &udp_on_destroy); 636 /* Create group lock if not yet (don't need to do so on UDP restart) */ 637 if (!tp->grp_lock) { 638 status = pj_grp_lock_create(tp->base.pool, NULL, &tp->grp_lock); 639 if (status != PJ_SUCCESS) 640 return status; 641 642 pj_grp_lock_add_ref(tp->grp_lock); 643 pj_grp_lock_add_handler(tp->grp_lock, tp->base.pool, tp, 644 &udp_on_destroy); 645 } 633 646 634 647 /* Register to ioqueue. */ … … 1076 1089 tp = (struct udp_transport*) transport; 1077 1090 1091 /* Pause the transport first, so that any active read loop spin will 1092 * quit as soon as possible. 1093 */ 1094 tp->is_paused = PJ_TRUE; 1095 1078 1096 if (option & PJSIP_UDP_TRANSPORT_DESTROY_SOCKET) { 1079 1097 char addr_buf[PJ_INET6_ADDRSTRLEN]; … … 1139 1157 } 1140 1158 1159 /* Make sure all udp_on_read_complete() loop spin are stopped */ 1160 do { 1161 pj_thread_sleep(1); 1162 } while (tp->read_loop_spin); 1163 1141 1164 /* Re-register new or existing socket to ioqueue. */ 1142 1165 status = register_to_ioqueue(tp);
Note: See TracChangeset
for help on using the changeset viewer.