Changeset 6155


Ignore:
Timestamp:
Feb 4, 2020 5:37:21 AM (5 years ago)
Author:
ming
Message:

Re #2229: Check to send pending data in the buffer even if the send completes immediately, since buffer may have been filled by then.

File:
1 edited

Legend:

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

    r6108 r6155  
    137137/* Forward decls */ 
    138138static pj_bool_t on_data_sent(pj_ice_strans *ice_st, pj_ssize_t sent); 
     139static void check_pending_send(pj_ice_strans *ice_st); 
    139140static void ice_st_on_destroy(void *obj); 
    140141static void destroy_ice_st(pj_ice_strans *ice_st); 
     
    16301631    if (comp->default_cand >= comp->cand_cnt) { 
    16311632        status = PJ_EINVALIDOP; 
    1632         goto on_return; 
     1633        if (call_cb) 
     1634            on_data_sent(ice_st, -status); 
     1635        return status; 
    16331636    } 
    16341637 
     
    17421745        on_data_sent(ice_st, (status == PJ_SUCCESS? data_len: -status)); 
    17431746    } else { 
    1744         pj_grp_lock_acquire(ice_st->grp_lock); 
    1745         if (ice_st->num_buf > 0) { 
    1746             ice_st->buf_idx = (ice_st->buf_idx + 1) % ice_st->num_buf; 
    1747             pj_assert (ice_st->buf_idx == ice_st->empty_idx); 
    1748         } 
    1749         ice_st->is_pending = PJ_FALSE; 
    1750         pj_grp_lock_release(ice_st->grp_lock); 
     1747        check_pending_send(ice_st); 
    17511748    } 
    17521749 
     
    20152012} 
    20162013 
    2017 /* Notifification when asynchronous send operation via STUN/TURN 
    2018  * has completed. 
    2019  */ 
    2020 static pj_bool_t on_data_sent(pj_ice_strans *ice_st, pj_ssize_t sent) 
    2021 { 
    2022     if (ice_st->destroy_req || !ice_st->is_pending) 
    2023         return PJ_TRUE; 
    2024  
    2025     if (ice_st->call_send_cb && ice_st->cb.on_data_sent) { 
    2026         (*ice_st->cb.on_data_sent)(ice_st, sent); 
    2027     } 
    2028  
     2014static void check_pending_send(pj_ice_strans *ice_st) 
     2015{ 
    20292016    pj_grp_lock_acquire(ice_st->grp_lock); 
    20302017 
     
    20332020     
    20342021    if (ice_st->num_buf > 0 && ice_st->buf_idx != ice_st->empty_idx) { 
    2035         /* There's still more pending send. Send it one by one. */ 
     2022        /* There's some pending send. Send it one by one. */ 
    20362023        pending_send *ps = &ice_st->send_buf[ice_st->buf_idx]; 
    20372024 
     
    20432030        pj_grp_lock_release(ice_st->grp_lock); 
    20442031    } 
     2032} 
     2033 
     2034/* Notifification when asynchronous send operation via STUN/TURN 
     2035 * has completed. 
     2036 */ 
     2037static pj_bool_t on_data_sent(pj_ice_strans *ice_st, pj_ssize_t sent) 
     2038{ 
     2039    if (ice_st->destroy_req || !ice_st->is_pending) 
     2040        return PJ_TRUE; 
     2041 
     2042    if (ice_st->call_send_cb && ice_st->cb.on_data_sent) { 
     2043        (*ice_st->cb.on_data_sent)(ice_st, sent); 
     2044    } 
     2045 
     2046    check_pending_send(ice_st); 
    20452047 
    20462048    return PJ_TRUE; 
Note: See TracChangeset for help on using the changeset viewer.