Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions system/lib/libc/musl/src/thread/__timedwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ int __timedwait_cp(volatile int *addr, int val,
// cp suffix in the function name means "cancellation point", so this wait can be cancelled
// by the users unless current threads cancelability is set to PTHREAD_CANCEL_DISABLE
// which may be either done by the user of __timedwait() function.
pthread_t self = pthread_self();
if (is_runtime_thread ||
pthread_self()->canceldisable != PTHREAD_CANCEL_DISABLE ||
pthread_self()->cancelasync) {
self->canceldisable != PTHREAD_CANCEL_DISABLE ||
self->cancelasync) {
double sleepUntilTime = emscripten_get_now() + msecsToSleep;
do {
if (pthread_self()->cancel) {
if (self->cancel) {
// The thread was canceled by pthread_cancel().
// In the case of cancelasync or PTHREAD_CANCEL_ENABLE we can just call
// __pthread_testcancel(), which won't return at all.
Expand Down
9 changes: 5 additions & 4 deletions system/lib/pthread/emscripten_futex_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ int emscripten_futex_wait(volatile void *addr, uint32_t val, double max_wait_ms)
emscripten_conditional_set_current_thread_status(EM_THREAD_STATUS_RUNNING, EM_THREAD_STATUS_WAITFUTEX);

#ifdef __EMSCRIPTEN_PTHREADS__
bool cancelable = pthread_self()->cancelasync == PTHREAD_CANCEL_ASYNCHRONOUS;
pthread_t self = pthread_self();
bool cancelable = self->cancelasync == PTHREAD_CANCEL_ASYNCHRONOUS;
#else
bool cancelable = false;
#endif
Expand Down Expand Up @@ -199,19 +200,19 @@ int emscripten_futex_wait(volatile void *addr, uint32_t val, double max_wait_ms)
// the queue, either from the call here directly after setting `sleeping` to
// 1, or from another callsite (e.g. the one in `emscripten_yield`).
if (!is_runtime_thread) {
__pthread_self()->sleeping = 1;
self->sleeping = 1;
_emscripten_process_dlopen_queue();
}
#endif
ret = __builtin_wasm_memory_atomic_wait32((int*)addr, val, max_wait_ns);
#ifdef EMSCRIPTEN_DYNAMIC_LINKING
if (!is_runtime_thread) {
__pthread_self()->sleeping = 0;
self->sleeping = 0;
_emscripten_process_dlopen_queue();
}
#endif
#ifdef __EMSCRIPTEN_PTHREADS__
if (cancelable && ret == ATOMICS_WAIT_TIMED_OUT && pthread_self()->cancel) {
if (cancelable && ret == ATOMICS_WAIT_TIMED_OUT && self->cancel) {
// Break out of the loop early if we were cancelled
break;
}
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_minimal_pthreads.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"a.out.js": 7364,
"a.out.js.gz": 3607,
"a.out.nodebug.wasm": 19265,
"a.out.nodebug.wasm": 19263,
"a.out.nodebug.wasm.gz": 8934,
"total": 26629,
"total": 26627,
"total_gz": 12541,
"sent": [
"a (memory)",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_minimal_pthreads_memgrowth.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"a.out.js": 7766,
"a.out.js.gz": 3812,
"a.out.nodebug.wasm": 19266,
"a.out.nodebug.wasm": 19264,
"a.out.nodebug.wasm.gz": 8935,
"total": 27032,
"total": 27030,
"total_gz": 12747,
"sent": [
"a (memory)",
Expand Down
Loading