Ignore:
Timestamp:
Jun 1, 2006 11:41:38 AM (17 years ago)
Author:
bennylp
Message:

Added pjsip_endpt_handle_events2(), which has an additional argument to report how many events are caught in the poll

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c

    r448 r486  
    583583} 
    584584 
    585 /* 
    586  * Handle events. 
    587  */ 
    588 PJ_DEF(pj_status_t) pjsip_endpt_handle_events(pjsip_endpoint *endpt, 
    589                                               const pj_time_val *max_timeout) 
     585 
     586PJ_DEF(pj_status_t) pjsip_endpt_handle_events2(pjsip_endpoint *endpt, 
     587                                               const pj_time_val *max_timeout, 
     588                                               unsigned *p_count) 
    590589{ 
    591590    /* timeout is 'out' var. This just to make compiler happy. */ 
    592591    pj_time_val timeout = { 0, 0}; 
     592    unsigned count = 0; 
     593    int c; 
    593594 
    594595    PJ_LOG(6, (THIS_FILE, "pjsip_endpt_handle_events()")); 
     
    598599     */ 
    599600    timeout.sec = timeout.msec = 0; 
    600     pj_timer_heap_poll( endpt->timer_heap, &timeout ); 
     601    c = pj_timer_heap_poll( endpt->timer_heap, &timeout ); 
     602    if (c > 0) 
     603        count += c; 
    601604 
    602605    /* timer_heap_poll should never ever returns negative value, or otherwise 
     
    613616 
    614617    /* Poll ioqueue. */ 
    615     if (pj_ioqueue_poll( endpt->ioqueue, &timeout) < 0) { 
     618    c = pj_ioqueue_poll( endpt->ioqueue, &timeout); 
     619    if (c < 0) { 
    616620        pj_thread_sleep(1); 
     621        if (p_count) 
     622            *p_count = count; 
    617623        return pj_get_netos_error(); 
    618624    } else { 
     625        count += c; 
     626        if (p_count) 
     627            *p_count = count; 
    619628        return PJ_SUCCESS; 
    620629    } 
     630} 
     631 
     632/* 
     633 * Handle events. 
     634 */ 
     635PJ_DEF(pj_status_t) pjsip_endpt_handle_events(pjsip_endpoint *endpt, 
     636                                              const pj_time_val *max_timeout) 
     637{ 
     638    return pjsip_endpt_handle_events2(endpt, max_timeout, NULL); 
    621639} 
    622640 
Note: See TracChangeset for help on using the changeset viewer.