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
20 changes: 15 additions & 5 deletions system/lib/libc/dynlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,21 @@ static void do_thread_sync_out(void* arg) {
*result = _emscripten_dlsync_self();
}

// Called once _emscripten_proxy_dlsync completes
static void done_thread_sync(void* arg) {
// Called when a thread exists prior to being able to completely sync operation.
// We can just ignore this case and report success.
static void thread_sync_cancelled(void* arg) {
struct promise_result* info = arg;
dbg("thread_sync_cancelled: promise=%p result=%i", info->promise, info->result);
emscripten_promise_resolve(info->promise, EM_PROMISE_FULFILL, NULL);
emscripten_promise_destroy(info->promise);
free(info);
}

// Called once do_thread_sync completes
static void thread_sync_done(void* arg) {
struct promise_result* info = arg;
em_promise_t promise = info->promise;
dbg("done_thread_sync: promise=%p result=%i", promise, info->result);
dbg("thread_sync_done: promise=%p result=%i", promise, info->result);
if (info->result) {
emscripten_promise_resolve(promise, EM_PROMISE_FULFILL, NULL);
} else {
Expand Down Expand Up @@ -389,8 +399,8 @@ int _emscripten_proxy_dlsync_async(pthread_t target_thread, em_promise_t promise
int rtn = emscripten_proxy_callback(dlopen_proxying_queue,
target_thread,
do_thread_sync,
done_thread_sync,
done_thread_sync,
thread_sync_done,
thread_sync_cancelled,
info);
if (!rtn) {
// If we failed to proxy, then the target thread is no longer alive and no
Expand Down
1 change: 0 additions & 1 deletion test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9412,7 +9412,6 @@ def test_pthread_dlopen(self):

@needs_dylink
@node_pthreads
@disabled('https://github.com/emscripten-core/emscripten/issues/18887')
def test_pthread_dlopen_many(self):
nthreads = 10
self.emcc_args += ['-Wno-experimental', '-pthread']
Expand Down