Ignore:
Timestamp:
Jan 2, 2008 8:24:10 AM (16 years ago)
Author:
bennylp
Message:

Ticket #437: reduce stack and pool usage on pjnath to make it work better on Symbian

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath/ice_session.c

    r1574 r1654  
    1818 */ 
    1919#include <pjnath/ice_session.h> 
    20 #include <pjnath/errno.h> 
    2120#include <pj/addr_resolv.h> 
    2221#include <pj/array.h> 
     
    262261        name = "ice%p"; 
    263262 
    264     pool = pj_pool_create(stun_cfg->pf, name, 4000, 4000, NULL); 
     263    pool = pj_pool_create(stun_cfg->pf, name, PJNATH_POOL_LEN_ICE_SESS,  
     264                          PJNATH_POOL_INC_ICE_SESS, NULL); 
    265265    ice = PJ_POOL_ZALLOC_T(pool, pj_ice_sess); 
    266266    ice->pool = pool; 
     
    558558    pj_ice_sess_cand *lcand; 
    559559    pj_status_t status = PJ_SUCCESS; 
    560     char tmp[128]; 
    561560 
    562561    PJ_ASSERT_RETURN(ice && comp_id &&  
     
    585584 
    586585 
    587     pj_ansi_strcpy(tmp, pj_inet_ntoa(lcand->addr.ipv4.sin_addr)); 
     586    pj_ansi_strcpy(ice->tmp.txt, pj_inet_ntoa(lcand->addr.ipv4.sin_addr)); 
    588587    LOG4((ice->obj_name,  
    589588         "Candidate %d added: comp_id=%d, type=%s, foundation=%.*s, " 
     
    594593         (int)lcand->foundation.slen, 
    595594         lcand->foundation.ptr, 
    596          tmp,  
     595         ice->tmp.txt,  
    597596         (int)pj_ntohs(lcand->addr.ipv4.sin_port), 
    598597         pj_inet_ntoa(lcand->base_addr.ipv4.sin_addr), 
     
    734733    const pj_ice_sess_cand *lcand = check->lcand; 
    735734    const pj_ice_sess_cand *rcand = check->rcand; 
    736     char laddr[CHECK_NAME_LEN]; 
     735    char laddr[PJ_INET6_ADDRSTRLEN]; 
    737736    int len; 
     737 
     738    PJ_CHECK_STACK(); 
    738739 
    739740    pj_ansi_strcpy(laddr, pj_inet_ntoa(lcand->addr.ipv4.sin_addr)); 
     
    761762} 
    762763 
    763 static void dump_checklist(const char *title, const pj_ice_sess *ice,  
     764static void dump_checklist(const char *title, pj_ice_sess *ice,  
    764765                           const pj_ice_sess_checklist *clist) 
    765766{ 
    766767    unsigned i; 
    767     char buffer[CHECK_NAME_LEN]; 
    768768 
    769769    LOG4((ice->obj_name, "%s", title)); 
     
    771771        const pj_ice_sess_check *c = &clist->checks[i]; 
    772772        LOG4((ice->obj_name, " %s (%s, state=%s)", 
    773              dump_check(buffer, sizeof(buffer), clist, c), 
     773             dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), clist, c), 
    774774             (c->nominated ? "nominated" : "not nominated"),  
    775775             check_state_name[c->state])); 
     
    785785                            pj_status_t err_code) 
    786786{ 
    787     char buf[CHECK_NAME_LEN]; 
    788  
    789787    pj_assert(check->state < PJ_ICE_SESS_CHECK_STATE_SUCCEEDED); 
    790788 
    791789    LOG5((ice->obj_name, "Check %s: state changed from %s to %s", 
    792          dump_check(buf, sizeof(buf), &ice->clist, check), 
     790         dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), &ice->clist, check), 
    793791         check_state_name[check->state], 
    794792         check_state_name[st])); 
     
    938936            if (reason != NULL) { 
    939937                /* Found duplicate, remove it */ 
    940                 char buf[CHECK_NAME_LEN]; 
    941  
    942938                LOG5((ice->obj_name, "Check %s pruned (%s)", 
    943                       dump_check(buf, sizeof(buf), &ice->clist,  
    944                                 &clist->checks[j]), 
     939                      dump_check(ice->tmp.txt, sizeof(ice->tmp.txt),  
     940                                 &ice->clist, &clist->checks[j]), 
    945941                      reason)); 
    946942 
     
    976972{ 
    977973    if (!ice->is_complete) { 
    978         char errmsg[PJ_ERR_MSG_SIZE]; 
    979  
    980974        ice->is_complete = PJ_TRUE; 
    981975        ice->ice_status = status; 
     
    983977        /* Log message */ 
    984978        LOG4((ice->obj_name, "ICE process complete, status=%s",  
    985              pj_strerror(status, errmsg, sizeof(errmsg)).ptr)); 
     979             pj_strerror(status, ice->tmp.errmsg,  
     980                         sizeof(ice->tmp.errmsg)).ptr)); 
    986981 
    987982        dump_checklist("Valid list", ice, &ice->valid_list); 
     
    10571052    if (check->err_code==PJ_SUCCESS && check->nominated) { 
    10581053        pj_ice_sess_comp *comp; 
    1059         char buf[CHECK_NAME_LEN]; 
    10601054 
    10611055        LOG5((ice->obj_name, "Check %d is successful and nominated", 
     
    10751069                    LOG5((ice->obj_name,  
    10761070                         "Check %s to be failed because state is %s", 
    1077                          dump_check(buf, sizeof(buf), &ice->clist, c),  
     1071                         dump_check(ice->tmp.txt, sizeof(ice->tmp.txt),  
     1072                                    &ice->clist, c),  
    10781073                         check_state_name[c->state])); 
    10791074                    check_set_state(ice, c, PJ_ICE_SESS_CHECK_STATE_FAILED, 
     
    10881083                        LOG5((ice->obj_name,  
    10891084                             "Cancelling check %s (In Progress)", 
    1090                              dump_check(buf, sizeof(buf), &ice->clist, c))); 
     1085                             dump_check(ice->tmp.txt, sizeof(ice->tmp.txt),  
     1086                                        &ice->clist, c))); 
    10911087                        pj_stun_session_cancel_req(comp->stun_sess,  
    10921088                                                   c->tdata, PJ_FALSE, 0); 
     
    13691365    const pj_ice_sess_cand *rcand; 
    13701366    pj_uint32_t prio; 
    1371     char buffer[128]; 
    13721367    pj_status_t status; 
    13731368 
     
    13791374    LOG5((ice->obj_name,  
    13801375         "Sending connectivity check for check %s",  
    1381          dump_check(buffer, sizeof(buffer), clist, check))); 
     1376         dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), clist, check))); 
    13821377 
    13831378    /* Create request */ 
     
    15541549    pj_ice_sess_checklist *clist; 
    15551550    const pj_ice_sess_cand *cand0; 
    1556     const pj_str_t *flist[PJ_ICE_MAX_CAND]; 
     1551    const pj_str_t *flist[PJ_ICE_MAX_CAND]; // XXX 
    15571552    pj_ice_rx_check *rcheck; 
    15581553    unsigned i, flist_cnt = 0; 
     1554    pj_time_val delay; 
     1555    pj_status_t status; 
    15591556 
    15601557    PJ_ASSERT_RETURN(ice, PJ_EINVAL); 
     
    16251622 
    16261623    /* Start periodic check */ 
    1627     return start_periodic_check(ice->stun_cfg.timer_heap, &clist->timer); 
     1624    /* We could start it immediately like below, but lets schedule timer  
     1625     * instead to reduce stack usage: 
     1626     * return start_periodic_check(ice->stun_cfg.timer_heap, &clist->timer); 
     1627     */ 
     1628    clist->timer.id = PJ_TRUE; 
     1629    delay.sec = delay.msec = 0; 
     1630    status = pj_timer_heap_schedule(ice->stun_cfg.timer_heap,  
     1631                                    &clist->timer, &delay); 
     1632    if (status != PJ_SUCCESS) { 
     1633        clist->timer.id = PJ_FALSE; 
     1634    } 
     1635 
     1636    return status; 
    16281637} 
    16291638 
     
    16621671    pj_ice_sess_checklist *clist; 
    16631672    pj_stun_xor_mapped_addr_attr *xaddr; 
    1664     char buffer[CHECK_NAME_LEN]; 
    16651673    unsigned i; 
    16661674 
     
    17311739        LOG4((ice->obj_name,  
    17321740             "Check %s%s: connectivity check FAILED: %s", 
    1733              dump_check(buffer, sizeof(buffer), &ice->clist, check), 
     1741             dump_check(ice->tmp.txt, sizeof(ice->tmp.txt),  
     1742                        &ice->clist, check), 
    17341743             (check->nominated ? " (nominated)" : " (not nominated)"), 
    17351744             errmsg)); 
     
    17541763        LOG4((ice->obj_name,  
    17551764             "Check %s%s: connectivity check FAILED: source address mismatch", 
    1756              dump_check(buffer, sizeof(buffer), &ice->clist, check), 
     1765             dump_check(ice->tmp.txt, sizeof(ice->tmp.txt),  
     1766                        &ice->clist, check), 
    17571767             (check->nominated ? " (nominated)" : " (not nominated)"))); 
    17581768        check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED, status); 
     
    17801790    LOG4((ice->obj_name,  
    17811791         "Check %s%s: connectivity check SUCCESS", 
    1782          dump_check(buffer, sizeof(buffer), &ice->clist, check), 
     1792         dump_check(ice->tmp.txt, sizeof(ice->tmp.txt),  
     1793                    &ice->clist, check), 
    17831794         (check->nominated ? " (nominated)" : " (not nominated)"))); 
    17841795 
     
    23582369                                           NULL, src_addr, src_addr_len); 
    23592370        if (status != PJ_SUCCESS) { 
    2360             char errmsg[PJ_ERR_MSG_SIZE]; 
    2361             pj_strerror(status, errmsg, sizeof(errmsg)); 
     2371            pj_strerror(status, ice->tmp.errmsg, sizeof(ice->tmp.errmsg)); 
    23622372            LOG4((ice->obj_name, "Error processing incoming message: %s", 
    2363                   errmsg)); 
     2373                  ice->tmp.errmsg)); 
    23642374        } 
    23652375    } else { 
Note: See TracChangeset for help on using the changeset viewer.