-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
n-api: fix dead lock if multi push events #58724
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
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
@milkpotatoes would it be possible to add a test case? That would help use see the problem more easily as well as make sure its not regressed in the future. |
- add waiting_task_size to record waiting push events - compare max_queue_size before queue.size which would be faster Signed-off-by: milkpotatoes <chenshulin5@huawei.com>
3547016
to
e2014e6
Compare
@@ -518,6 +521,7 @@ class ThreadSafeFunction : public node::AsyncResource { | |||
// means we don't need the mutex to read them. | |||
void* context; | |||
size_t max_queue_size; | |||
size_t waiting_task_size; |
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.
This seems like it adds an extra variable when we could also just call Signal()
unconditionally with the same effect? This class already has a very large state space (one of the worst examples I've seen), I'd try to avoid another piece of state even if its usage is localized to managing cond
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, this approach seems acceptable. However, it may introduce unnecessary signal calls, which could incur additional performance overhead.
fix #58723