- Timestamp:
- Aug 28, 2018 5:42:25 AM (6 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_config.h
r5812 r5869 773 773 774 774 /** 775 * Initial timeout interval to be applied to incoming transports (i.e. server 776 * side) when no data received after a successful connection. Value is in 777 * seconds. Disable the timeout by setting it to 0. 778 * 779 * Note that even when this is disable, the connection might still get closed 780 * when it is idle or not referred anymore. Have a look at \a 781 * PJSIP_TRANSPORT_SERVER_IDLE_TIME 782 * 783 * Default: 0 (disabled) 784 */ 785 #ifndef PJSIP_TCP_INITIAL_TIMEOUT 786 # define PJSIP_TCP_INITIAL_TIMEOUT 0 787 #endif 788 789 /** 775 790 * Set the interval to send keep-alive packet for TLS transports. 776 791 * If the value is zero, keep-alive will be disabled for TLS. -
pjproject/trunk/pjsip/include/pjsip/sip_transport_tcp.h
r5649 r5869 112 112 */ 113 113 pj_sockopt_params sockopt_params; 114 115 116 /** 117 * Intial timeout interval to be applied to incoming transports 118 * (i.e. server side) when no data received after a successful connection. 119 * 120 * Default: PJSIP_TCP_INITIAL_TIMEOUT 121 */ 122 unsigned initial_timeout; 114 123 115 124 } pjsip_tcp_transport_cfg; -
pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c
r5833 r5869 64 64 pj_bool_t reuse_addr; 65 65 unsigned async_cnt; 66 unsigned initial_timeout; 66 67 67 68 /* Group lock to be used by TCP listener and ioqueue key */ … … 124 125 /* Group lock to be used by TCP transport and ioqueue key */ 125 126 pj_grp_lock_t *grp_lock; 127 128 /* Initial timer. */ 129 pj_timer_entry initial_timer; 126 130 }; 127 131 … … 237 241 cfg->async_cnt = 1; 238 242 cfg->reuse_addr = PJSIP_TCP_TRANSPORT_REUSEADDR; 243 cfg->initial_timeout = PJSIP_TCP_INITIAL_TIMEOUT; 239 244 } 240 245 … … 392 397 listener->reuse_addr = cfg->reuse_addr; 393 398 listener->async_cnt = cfg->async_cnt; 399 listener->initial_timeout = cfg->initial_timeout; 394 400 pj_memcpy(&listener->qos_params, &cfg->qos_params, 395 401 sizeof(cfg->qos_params)); … … 594 600 /* TCP keep-alive timer callback */ 595 601 static void tcp_keep_alive_timer(pj_timer_heap_t *th, pj_timer_entry *e); 602 603 /* TCP initial timer callback */ 604 static void tcp_initial_timer(pj_timer_heap_t *th, pj_timer_entry *e); 596 605 597 606 /* Clean up TCP resources */ … … 715 724 pj_strdup(tcp->base.pool, &tcp->ka_pkt, &ka_pkt); 716 725 726 /* Initialize initial timer. */ 727 if (is_server && listener->initial_timeout) { 728 tcp->initial_timer.user_data = (void*)tcp; 729 tcp->initial_timer.cb = &tcp_initial_timer; 730 731 pj_time_val delay = { 0 }; 732 delay.sec = listener->initial_timeout; 733 pjsip_endpt_schedule_timer(listener->endpt, 734 &tcp->initial_timer, 735 &delay); 736 tcp->initial_timer.id = PJ_TRUE; 737 } 738 717 739 /* Done setting up basic transport. */ 718 740 *p_tcp = tcp; … … 810 832 pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->ka_timer); 811 833 tcp->ka_timer.id = PJ_FALSE; 834 } 835 836 /* Stop initial timer. */ 837 if (tcp->initial_timer.id) { 838 pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->initial_timer); 839 tcp->initial_timer.id = PJ_FALSE; 812 840 } 813 841 … … 1340 1368 } 1341 1369 1370 /* Stop initial timer. */ 1371 if (tcp->initial_timer.id) { 1372 pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->initial_timer); 1373 tcp->initial_timer.id = PJ_FALSE; 1374 } 1375 1342 1376 return PJ_SUCCESS; 1343 1377 } … … 1366 1400 tcp->is_closing++; 1367 1401 return PJ_FALSE; 1402 } 1403 1404 if (tcp->initial_timer.id) { 1405 pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->initial_timer); 1406 tcp->initial_timer.id = PJ_FALSE; 1368 1407 } 1369 1408 … … 1585 1624 } 1586 1625 1626 /* Transport keep-alive timer callback */ 1627 static void tcp_initial_timer(pj_timer_heap_t *th, pj_timer_entry *e) 1628 { 1629 pj_status_t status = PJ_ETIMEDOUT; 1630 struct tcp_transport *tcp = (struct tcp_transport*) e->user_data; 1631 1632 PJ_UNUSED_ARG(th); 1633 1634 tcp_init_shutdown(tcp, status); 1635 } 1587 1636 1588 1637 PJ_DEF(pj_sock_t) pjsip_tcp_transport_get_socket(pjsip_transport *transport)
Note: See TracChangeset
for help on using the changeset viewer.