diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-04-22 22:38:46 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-04-22 22:38:46 +0000 |
commit | 7b12b5b208876599394d724a4d0a6e925a2ff417 (patch) | |
tree | 6448cdd9a0cfa5a41a030c366e30c3a475effca4 /pjlib | |
parent | 8223318098b8106e4ff930ee649dab58cbb475e7 (diff) |
Workaround for pj_thread_sleep() failure with ETIMEDOUT in MacOS X (thanks Daniel Mikusa)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1939 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r-- | pjlib/src/pj/os_core_unix.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c index 4ce63a7a..250868df 100644 --- a/pjlib/src/pj/os_core_unix.c +++ b/pjlib/src/pj/os_core_unix.c @@ -705,8 +705,21 @@ PJ_DEF(pj_status_t) pj_thread_sleep(unsigned msec) usleep(msec * 1000); + /* MacOS X (reported on 10.5) seems to always set errno to ETIMEDOUT. + * It does so because usleep() is declared to return int, and we're + * supposed to check for errno only when usleep() returns non-zero. + * Unfortunately, usleep() is declared to return void in other platforms + * so it's not possible to always check for the return value (unless + * we add a detection routine in autoconf). + * + * As a workaround, here we check if ETIMEDOUT is returned and + * return successfully if it is. + */ + if (pj_get_native_os_error() == ETIMEDOUT) + return PJ_SUCCESS; + return pj_get_os_error(); -; + #endif /* PJ_RTEMS */ } |