Changeset 5090


Ignore:
Timestamp:
May 11, 2015 5:57:50 AM (10 years ago)
Author:
ming
Message:

Fixed #1851: Runtime configuration of TCP and TLS keep alive intervals

Thanks to Michele Cicciotti for the patch.

Location:
pjproject/trunk/pjsip
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_config.h

    r4924 r5090  
    218218    } regc; 
    219219 
     220    /** TCP transport settings */ 
     221    struct { 
     222        /** 
     223         * Set the interval to send keep-alive packet for TCP transports. 
     224         * If the value is zero, keep-alive will be disabled for TCP. 
     225         * 
     226         * Default is PJSIP_TCP_KEEP_ALIVE_INTERVAL. 
     227         */ 
     228        long keep_alive_interval; 
     229 
     230    } tcp; 
     231 
     232    /** TLS transport settings */ 
     233    struct { 
     234        /** 
     235         * Set the interval to send keep-alive packet for TLS transports. 
     236         * If the value is zero, keep-alive will be disabled for TLS. 
     237         * 
     238         * Default is PJSIP_TLS_KEEP_ALIVE_INTERVAL. 
     239         */ 
     240        long keep_alive_interval; 
     241 
     242    } tls; 
     243 
    220244} pjsip_cfg_t; 
    221245 
     
    650674 * If the value is zero, keep-alive will be disabled for TCP. 
    651675 * 
     676 * This option can be changed in run-time by settting 
     677 * \a tcp.keep_alive_interval field of pjsip_cfg(). 
     678 * 
    652679 * Default: 90 (seconds) 
    653680 * 
     
    672699 * Set the interval to send keep-alive packet for TLS transports. 
    673700 * If the value is zero, keep-alive will be disabled for TLS. 
     701 * 
     702 * This option can be changed in run-time by settting 
     703 * \a tls.keep_alive_interval field of pjsip_cfg(). 
    674704 * 
    675705 * Default: 90 (seconds) 
  • pjproject/trunk/pjsip/src/pjsip/sip_config.c

    r4899 r5090  
    5050    { 
    5151        PJSIP_REGISTER_CLIENT_CHECK_CONTACT 
     52    }, 
     53 
     54    /* TCP transport settings */ 
     55    { 
     56        PJSIP_TCP_KEEP_ALIVE_INTERVAL 
     57    }, 
     58 
     59    /* TLS transport settings */ 
     60    { 
     61        PJSIP_TLS_KEEP_ALIVE_INTERVAL 
    5262    } 
    5363}; 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c

    r5000 r5090  
    11411141            } 
    11421142            /* Start keep-alive timer */ 
    1143             if (PJSIP_TCP_KEEP_ALIVE_INTERVAL) { 
    1144                 pj_time_val delay = {PJSIP_TCP_KEEP_ALIVE_INTERVAL, 0}; 
     1143            if (pjsip_cfg()->tcp.keep_alive_interval) { 
     1144                pj_time_val delay = {pjsip_cfg()->tcp.keep_alive_interval, 0}; 
    11451145                pjsip_endpt_schedule_timer(listener->endpt,  
    11461146                                           &tcp->ka_timer,  
     
    15001500 
    15011501    /* Start keep-alive timer */ 
    1502     if (PJSIP_TCP_KEEP_ALIVE_INTERVAL) { 
    1503         pj_time_val delay = { PJSIP_TCP_KEEP_ALIVE_INTERVAL, 0 }; 
     1502    if (pjsip_cfg()->tcp.keep_alive_interval) { 
     1503        pj_time_val delay = { pjsip_cfg()->tcp.keep_alive_interval, 0 }; 
    15041504        pjsip_endpt_schedule_timer(tcp->base.endpt, &tcp->ka_timer,  
    15051505                                   &delay); 
     
    15271527    PJ_TIME_VAL_SUB(now, tcp->last_activity); 
    15281528 
    1529     if (now.sec > 0 && now.sec < PJSIP_TCP_KEEP_ALIVE_INTERVAL) { 
     1529    if (now.sec > 0 && now.sec < pjsip_cfg()->tcp.keep_alive_interval) { 
    15301530        /* There has been activity, so don't send keep-alive */ 
    1531         delay.sec = PJSIP_TCP_KEEP_ALIVE_INTERVAL - now.sec; 
     1531        delay.sec = pjsip_cfg()->tcp.keep_alive_interval - now.sec; 
    15321532        delay.msec = 0; 
    15331533 
     
    15561556 
    15571557    /* Register next keep-alive */ 
    1558     delay.sec = PJSIP_TCP_KEEP_ALIVE_INTERVAL; 
     1558    delay.sec = pjsip_cfg()->tcp.keep_alive_interval; 
    15591559    delay.msec = 0; 
    15601560 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c

    r5000 r5090  
    12821282    } else { 
    12831283        /* Start keep-alive timer */ 
    1284         if (PJSIP_TLS_KEEP_ALIVE_INTERVAL) { 
    1285             pj_time_val delay = {PJSIP_TLS_KEEP_ALIVE_INTERVAL, 0}; 
     1284        if (pjsip_cfg()->tls.keep_alive_interval) { 
     1285            pj_time_val delay = {pjsip_cfg()->tls.keep_alive_interval, 0}; 
    12861286            pjsip_endpt_schedule_timer(listener->endpt,  
    12871287                                       &tls->ka_timer,  
     
    17481748 
    17491749    /* Start keep-alive timer */ 
    1750     if (PJSIP_TLS_KEEP_ALIVE_INTERVAL) { 
    1751         pj_time_val delay = { PJSIP_TLS_KEEP_ALIVE_INTERVAL, 0 }; 
     1750    if (pjsip_cfg()->tls.keep_alive_interval) { 
     1751        pj_time_val delay = { pjsip_cfg()->tls.keep_alive_interval, 0 }; 
    17521752        pjsip_endpt_schedule_timer(tls->base.endpt, &tls->ka_timer,  
    17531753                                   &delay); 
     
    17811781    PJ_TIME_VAL_SUB(now, tls->last_activity); 
    17821782 
    1783     if (now.sec > 0 && now.sec < PJSIP_TLS_KEEP_ALIVE_INTERVAL) { 
     1783    if (now.sec > 0 && now.sec < pjsip_cfg()->tls.keep_alive_interval) { 
    17841784        /* There has been activity, so don't send keep-alive */ 
    1785         delay.sec = PJSIP_TLS_KEEP_ALIVE_INTERVAL - now.sec; 
     1785        delay.sec = pjsip_cfg()->tls.keep_alive_interval - now.sec; 
    17861786        delay.msec = 0; 
    17871787 
     
    18111811 
    18121812    /* Register next keep-alive */ 
    1813     delay.sec = PJSIP_TLS_KEEP_ALIVE_INTERVAL; 
     1813    delay.sec = pjsip_cfg()->tls.keep_alive_interval; 
    18141814    delay.msec = 0; 
    18151815 
Note: See TracChangeset for help on using the changeset viewer.