diff options
author | Benny Prijono <bennylp@teluu.com> | 2010-01-13 13:09:45 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2010-01-13 13:09:45 +0000 |
commit | 8cc7aef25ecc698b6fdfa620877f72e6b8dd536f (patch) | |
tree | 40e3c7c8df20a5b26d95543285145348a18009db /pjlib | |
parent | d4663d0cbfd495529f7ce486d9f9d36f7969bc50 (diff) |
Initial OpenBSD fixes (#994):
pjlib:
- Autoconf fixes in detecting header availability
- Undefined sched_get_priority_max() and sched_get_priority_min()
- protect with #ifdef _POSIX_PRIORITY_SCHEDULING, and
- return hardcoded (0, 31) if __OpenBSD__ macro is declared
- Better GUID generation
pjlib-test:
- Reduce the loop in PJILB activesock test
- Fixed bug in ioqueue unregistration test which caused assertion error in destroying mutex
pjlib-util-test:
- Fixed bug in pjlib-util resolver test
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3057 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r-- | pjlib/src/pj/guid_simple.c | 10 | ||||
-rw-r--r-- | pjlib/src/pj/os_core_unix.c | 14 | ||||
-rw-r--r-- | pjlib/src/pjlib-test/activesock.c | 11 | ||||
-rw-r--r-- | pjlib/src/pjlib-test/ioq_unreg.c | 1 |
4 files changed, 31 insertions, 5 deletions
diff --git a/pjlib/src/pj/guid_simple.c b/pjlib/src/pj/guid_simple.c index 83870299..728d87e5 100644 --- a/pjlib/src/pj/guid_simple.c +++ b/pjlib/src/pj/guid_simple.c @@ -67,10 +67,12 @@ PJ_DEF(pj_str_t*) pj_generate_unique_string(pj_str_t *str) pj_assert(PJ_GUID_STRING_LENGTH % 2 == 0); for (p=str->ptr, end=p+PJ_GUID_STRING_LENGTH; p<end; ) { - /* Assumes rand() only has 16bit randomness */ - unsigned short val = pj_rand(); - *p++ = guid_chars[(val >> 8) & 63]; - *p++ = guid_chars[(val & 0xFF) & 63]; + pj_uint32_t rand_val = pj_rand(); + pj_uint32_t rand_idx = RAND_MAX; + + for ( ; rand_idx>0 && p<end; rand_idx>>=8, rand_val>>=8, p++) { + *p = guid_chars[(rand_val & 0xFF) & 63]; + } } str->slen = PJ_GUID_STRING_LENGTH; diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c index 00094cf3..c46fbf09 100644 --- a/pjlib/src/pj/os_core_unix.c +++ b/pjlib/src/pj/os_core_unix.c @@ -308,7 +308,14 @@ PJ_DEF(int) pj_thread_get_prio_min(pj_thread_t *thread) if (rc != 0) return -1; +#if defined _POSIX_PRIORITY_SCHEDULING return sched_get_priority_min(policy); +#elif defined __OpenBSD__ + return 0; +#else + pj_assert("pj_thread_get_prio_min() not supported!"); + return 0; +#endif } @@ -325,7 +332,14 @@ PJ_DEF(int) pj_thread_get_prio_max(pj_thread_t *thread) if (rc != 0) return -1; +#if defined _POSIX_PRIORITY_SCHEDULING return sched_get_priority_max(policy); +#elif defined __OpenBSD__ + return 31; +#else + pj_assert("pj_thread_get_prio_max() not supported!"); + return 0; +#endif } diff --git a/pjlib/src/pjlib-test/activesock.c b/pjlib/src/pjlib-test/activesock.c index bcbf4598..aaa2b672 100644 --- a/pjlib/src/pjlib-test/activesock.c +++ b/pjlib/src/pjlib-test/activesock.c @@ -337,7 +337,7 @@ static pj_bool_t tcp_on_data_sent(pj_activesock_t *asock, static int tcp_perf_test(void) { - enum { COUNT=100000 }; + enum { COUNT=10000 }; pj_pool_t *pool = NULL; pj_ioqueue_t *ioqueue = NULL; pj_sock_t sock1=PJ_INVALID_SOCKET, sock2=PJ_INVALID_SOCKET; @@ -436,6 +436,15 @@ static int tcp_perf_test(void) } } } + +#ifndef PJ_SYMBIAN + for (;;) { + pj_time_val timeout = {0, 10}; + if (pj_ioqueue_poll(ioqueue, &timeout) < 1) + break; + } +#endif + } /* Wait until everything has been sent/received */ diff --git a/pjlib/src/pjlib-test/ioq_unreg.c b/pjlib/src/pjlib-test/ioq_unreg.c index 6b19ed1f..f30510d4 100644 --- a/pjlib/src/pjlib-test/ioq_unreg.c +++ b/pjlib/src/pjlib-test/ioq_unreg.c @@ -93,6 +93,7 @@ static void on_read_complete(pj_ioqueue_key_t *key, if (PJ_TIME_VAL_GTE(now, time_to_unregister)) { sock_data.unregistered = 1; pj_ioqueue_unregister(key); + pj_mutex_unlock(sock_data.mutex); return; } } |