-
Notifications
You must be signed in to change notification settings - Fork 749
Implement POSIX semaphore support #1345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if (!append_thread_info_node(info_node)) | ||
| goto fail3; | ||
|
|
||
| if (!bh_hash_map_insert(sem_info_map, (void *)name, info_node)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An issue for multi-thread: suppose thread A opens a semaphore with a name, and the info_node is added into both thread_info_map and sem_info_map, and B opens a semaphore with the same name, this time it will just return success in L1140 as is has been created. And then thread A exits, the semaphore may be destroyed during thread exiting, but thread B still uses it, which might cause core dump.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it will check the status of sem before using it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
| if (!append_thread_info_node(info_node)) | ||
| goto fail3; | ||
|
|
||
| if (!bh_hash_map_insert(sem_info_map, (void *)name, info_node)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
| * semaphore. The semaphore is identified by name. For details of | ||
| * the construction of name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"For details of the construction of name" this statement seems incomplete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, docs added.
Most description of these APIs is from https://man7.org/linux/man-pages/man3/sem_open.3.html
|
|
||
| #include "bh_common.h" | ||
| #include "bh_log.h" | ||
| #include "platform_api_extension.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should include"bh_platform.h" instead, "platform_api_extension.h" is an internal file of core/shared and is included in "bh_platform.h", normally we don't include it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, this was added by clangd in my editor, I'll remove it.
…e#1345) Implement POSIX semaphore support for linux platform
…e#1345) Implement POSIX semaphore support for linux platform
No description provided.