Changeset 486


Ignore:
Timestamp:
Jun 1, 2006 11:41:38 AM (18 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

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

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

    r248 r486  
    117117 
    118118/** 
     119 * Handle events with additional info about number of events that 
     120 * have been handled. 
     121 * 
     122 * @param endpt         The endpoint. 
     123 * @param max_timeout   Maximum time to wait for events, or NULL to wait forever 
     124 *                      until event is received. 
     125 * @param count         Optional argument to receive the number of events that 
     126 *                      have been handled by the function. 
     127 * 
     128 * @return              PJ_SUCCESS on success. 
     129 */ 
     130PJ_DECL(pj_status_t) pjsip_endpt_handle_events2(pjsip_endpoint *endpt, 
     131                                                const pj_time_val *max_timeout, 
     132                                                unsigned *count); 
     133/** 
    119134 * Schedule timer to endpoint's timer heap. Application must poll the endpoint 
    120135 * periodically (by calling #pjsip_endpt_handle_events) to ensure that the 
  • 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.