Skip to content

Commit be6e8fd

Browse files
committed
Fix browser.test_pthreads_started_in_worker test failure
1 parent 96fb4df commit be6e8fd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

system/lib/libc/musl/src/thread/__timedwait.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ int __timedwait_cp(volatile int *addr, int val,
5757
#ifdef __EMSCRIPTEN__
5858
pthread_t self = __pthread_self();
5959
double msecsToSleep = top ? (top->tv_sec * 1000 + top->tv_nsec / 1000000.0) : INFINITY;
60-
int is_main_thread = emscripten_is_main_browser_thread();
60+
int is_runtime_thread = emscripten_is_main_runtime_thread();
6161

62-
// Main browser thread may need to run proxied calls, so sleep in very small slices to be responsive.
63-
const double maxMsecsSliceToSleep = is_main_thread ? 1 : 100;
62+
// Main runtime thread may need to run proxied calls, so sleep in very small slices to be responsive.
63+
const double maxMsecsSliceToSleep = is_runtime_thread ? 1 : 100;
6464

65-
if (is_main_thread || self->cancelasync) {
65+
if (is_runtime_thread || !self->canceldisable || self->cancelasync) {
6666
double sleepUntilTime = emscripten_get_now() + msecsToSleep;
6767
do {
6868
if (self->cancel) {
@@ -72,7 +72,7 @@ int __timedwait_cp(volatile int *addr, int val,
7272
return ECANCELED;
7373
}
7474
// Assist other threads by executing proxied operations that are effectively singlethreaded.
75-
if (is_main_thread) emscripten_main_thread_process_queued_calls();
75+
if (is_runtime_thread) emscripten_main_thread_process_queued_calls();
7676
// Must wait in slices in case this thread is cancelled in between.
7777
double waitMsecs = sleepUntilTime - emscripten_get_now();
7878
if (waitMsecs <= 0) {

system/lib/libc/musl/src/thread/__wait.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ void __wait(volatile int *addr, volatile int *waiters, int val, int priv)
1313
if (waiters) a_inc(waiters);
1414
#ifdef __EMSCRIPTEN__
1515
pthread_t self = __pthread_self();
16-
int is_main_thread = emscripten_is_main_runtime_thread();
16+
int is_runtime_thread = emscripten_is_main_runtime_thread();
1717

1818
// Main runtime thread may need to run proxied calls, so sleep in very small slices to be responsive.
19-
const double maxMsecsSliceToSleep = is_main_thread ? 1 : 100;
19+
const double maxMsecsSliceToSleep = is_runtime_thread ? 1 : 100;
2020

2121
while (*addr==val) {
2222
if (self->cancelasync) {
@@ -28,7 +28,7 @@ void __wait(volatile int *addr, volatile int *waiters, int val, int priv)
2828
return;
2929
}
3030
// Assist other threads by executing proxied operations that are effectively singlethreaded.
31-
if (is_main_thread) emscripten_main_thread_process_queued_calls();
31+
if (is_runtime_thread) emscripten_main_thread_process_queued_calls();
3232
e = emscripten_futex_wait(addr, val, maxMsecsSliceToSleep);
3333
} while(e == -ETIMEDOUT);
3434
} else {

0 commit comments

Comments
 (0)