Skip to content

Separate dlopen_async callback data from dso struct. NFC - #18361

Merged
sbc100 merged 1 commit into
mainfrom
dlopen_async
Dec 13, 2022
Merged

sbc100 merged 1 commit into
mainfrom
dlopen_async

Conversation

@sbc100

@sbc100 sbc100 commented Dec 13, 2022

Copy link
Copy Markdown
Collaborator

Using fields embedded in the DSO struct (which is shared between threads) is not thread safe.

This is needed as part of my fix for #18345

@sbc100

sbc100 commented Dec 13, 2022

Copy link
Copy Markdown
Collaborator Author

Also includes an added assert and a cleanup of a long JS line of code, which I made while working on #18345

@sbc100
sbc100 requested review from dschuff and kripken December 13, 2022 01:26
Comment thread system/lib/libc/dynlink.c
pthread_rwlock_unlock(&lock);
p->onerror(p->user_data);
free(p);
data->onerror(data->user_data);

@kripken kripken Dec 13, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't onerror take 2 params like onsuccess? In JS they both appear to.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For theese internal JS callbacks they both take two arguments yes. For those we use locally/internal dlopen_js_onsuccess and dlopen_js_onerror.

For the actual user callback passed to emscripten_dlopen (which is the user-facing ASI which doesn't change in this PR which is NFC) the onerror only takes one argument. This is because when emscripten_dlopen is called there is no handle to a dll, and no handle is ever passed back to the user, except in the success case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now, thanks!

Using fields embedded in the DSO struct (which is shared between
threads) is not thread safe.

This is needed as part of my fix for #18345
@sbc100
sbc100 merged commit 6b71809 into main Dec 13, 2022
@sbc100
sbc100 deleted the dlopen_async branch December 13, 2022 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants