summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/src/pj/guid_simple.c10
-rw-r--r--pjlib/src/pj/os_core_unix.c14
-rw-r--r--pjlib/src/pjlib-test/activesock.c11
-rw-r--r--pjlib/src/pjlib-test/ioq_unreg.c1
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;
}
}