diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-06-01 11:41:38 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-06-01 11:41:38 +0000 |
commit | ad70abbdad70cbc5e0c61b41531783290fe08f48 (patch) | |
tree | 329b30cede67acca24de9ea14cee1b80fe76eaa0 /pjsip/src | |
parent | a8f85a3825b8b3806de0801cfc981c77577eb211 (diff) |
Added pjsip_endpt_handle_events2(), which has an additional argument to report how many events are caught in the poll
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@486 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r-- | pjsip/src/pjsip/sip_endpoint.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c index 3ede0102..e04485dc 100644 --- a/pjsip/src/pjsip/sip_endpoint.c +++ b/pjsip/src/pjsip/sip_endpoint.c @@ -582,14 +582,15 @@ PJ_DEF(void) pjsip_endpt_release_pool( pjsip_endpoint *endpt, pj_pool_t *pool ) pj_mutex_unlock(endpt->mutex); } -/* - * Handle events. - */ -PJ_DEF(pj_status_t) pjsip_endpt_handle_events(pjsip_endpoint *endpt, - const pj_time_val *max_timeout) + +PJ_DEF(pj_status_t) pjsip_endpt_handle_events2(pjsip_endpoint *endpt, + const pj_time_val *max_timeout, + unsigned *p_count) { /* timeout is 'out' var. This just to make compiler happy. */ pj_time_val timeout = { 0, 0}; + unsigned count = 0; + int c; PJ_LOG(6, (THIS_FILE, "pjsip_endpt_handle_events()")); @@ -597,7 +598,9 @@ PJ_DEF(pj_status_t) pjsip_endpt_handle_events(pjsip_endpoint *endpt, * granularity, so we don't need to lock end endpoint. */ timeout.sec = timeout.msec = 0; - pj_timer_heap_poll( endpt->timer_heap, &timeout ); + c = pj_timer_heap_poll( endpt->timer_heap, &timeout ); + if (c > 0) + count += c; /* timer_heap_poll should never ever returns negative value, or otherwise * ioqueue_poll() will block forever! @@ -612,15 +615,30 @@ PJ_DEF(pj_status_t) pjsip_endpt_handle_events(pjsip_endpoint *endpt, } /* Poll ioqueue. */ - if (pj_ioqueue_poll( endpt->ioqueue, &timeout) < 0) { + c = pj_ioqueue_poll( endpt->ioqueue, &timeout); + if (c < 0) { pj_thread_sleep(1); + if (p_count) + *p_count = count; return pj_get_netos_error(); } else { + count += c; + if (p_count) + *p_count = count; return PJ_SUCCESS; } } /* + * Handle events. + */ +PJ_DEF(pj_status_t) pjsip_endpt_handle_events(pjsip_endpoint *endpt, + const pj_time_val *max_timeout) +{ + return pjsip_endpt_handle_events2(endpt, max_timeout, NULL); +} + +/* * Schedule timer. */ PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt, |