Ignore:
Timestamp:
Jun 19, 2014 9:42:02 AM (10 years ago)
Author:
nanang
Message:

Fix #1773: Added group lock to SIP transport to avoid race condition between transport callback and destroy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c

    r4860 r4862  
    16941694    asock_cfg.concurrency = ssock->param.concurrency; 
    16951695    asock_cfg.whole_data = PJ_TRUE; 
     1696     
     1697    /* If listener socket has group lock, automatically create group lock 
     1698     * for the new socket. 
     1699     */ 
     1700    if (ssock_parent->param.grp_lock) { 
     1701        pj_grp_lock_t *glock; 
     1702 
     1703        status = pj_grp_lock_create(ssock->pool, NULL, &glock); 
     1704        if (status != PJ_SUCCESS) 
     1705            goto on_return; 
     1706 
     1707        /* Temporarily add ref the group lock until active socket creation, 
     1708         * to make sure that group lock is destroyed if the active socket 
     1709         * creation fails. 
     1710         */ 
     1711        pj_grp_lock_add_ref(glock); 
     1712        asock_cfg.grp_lock = ssock->param.grp_lock = glock; 
     1713    } 
    16961714 
    16971715    pj_bzero(&asock_cb, sizeof(asock_cb)); 
     
    17071725                                  ssock, 
    17081726                                  &ssock->asock); 
     1727 
     1728    /* This will destroy the group lock if active socket creation fails */ 
     1729    if (asock_cfg.grp_lock) { 
     1730        pj_grp_lock_dec_ref(asock_cfg.grp_lock); 
     1731    } 
    17091732 
    17101733    if (status != PJ_SUCCESS) 
     
    21222145    /* Last known OpenSSL error code */ 
    21232146    info->last_native_err = ssock->last_err; 
     2147 
     2148    /* Group lock */ 
     2149    info->grp_lock = ssock->param.grp_lock; 
    21242150 
    21252151    return PJ_SUCCESS; 
     
    24892515    asock_cfg.concurrency = ssock->param.concurrency; 
    24902516    asock_cfg.whole_data = PJ_TRUE; 
     2517    asock_cfg.grp_lock = ssock->param.grp_lock; 
    24912518 
    24922519    pj_bzero(&asock_cb, sizeof(asock_cb)); 
     
    25752602    asock_cfg.concurrency = ssock->param.concurrency; 
    25762603    asock_cfg.whole_data = PJ_TRUE; 
     2604    asock_cfg.grp_lock = ssock->param.grp_lock; 
    25772605 
    25782606    pj_bzero(&asock_cb, sizeof(asock_cb)); 
Note: See TracChangeset for help on using the changeset viewer.