Changeset 5668


Ignore:
Timestamp:
Sep 29, 2017 2:43:05 AM (7 years ago)
Author:
ming
Message:

Fix #2048: Add compile time option to disable sleep in sip endpoint's handle events on ioqueue polling's error

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

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

    r5557 r5668  
    377377#endif 
    378378 
     379/** 
     380 * Specify if #pjsip_endpt_handle_events() should sleep if ioqueue poll 
     381 * returns error. 
     382 * 
     383 * Default is 1 (yes). 
     384 */ 
     385 
     386#ifndef PJSIP_HANDLE_EVENTS_HAS_SLEEP_ON_ERR 
     387#   define PJSIP_HANDLE_EVENTS_HAS_SLEEP_ON_ERR     1 
     388#endif 
    379389 
    380390/** 
  • pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c

    r5397 r5668  
    3535#include <pj/errno.h> 
    3636#include <pj/lock.h> 
     37#include <pj/math.h> 
    3738 
    3839#define PJSIP_EX_NO_MEMORY  pj_NO_MEMORY_EXCEPTION() 
     
    700701                                               unsigned *p_count) 
    701702{ 
     703    enum { MAX_TIMEOUT_ON_ERR = 10 }; 
    702704    /* timeout is 'out' var. This just to make compiler happy. */ 
    703705    pj_time_val timeout = { 0, 0}; 
     
    743745        if (c < 0) { 
    744746            pj_status_t err = pj_get_netos_error(); 
    745             pj_thread_sleep(PJ_TIME_VAL_MSEC(timeout)); 
     747#if PJSIP_HANDLE_EVENTS_HAS_SLEEP_ON_ERR 
     748            unsigned msec = PJ_TIME_VAL_MSEC(timeout); 
     749            pj_thread_sleep(PJ_MIN(msec, MAX_TIMEOUT_ON_ERR)); 
     750#endif 
     751 
    746752            if (p_count) 
    747753                *p_count = count; 
Note: See TracChangeset for help on using the changeset viewer.