-
Notifications
You must be signed in to change notification settings - Fork 532
RUBY-2869 Do not use mutexes in finalizers #2417
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
RUBY-2869 Do not use mutexes in finalizers #2417
Conversation
kill_spec.db_name, | ||
kill_spec.service_id | ||
].join(MSG_SEPARATOR) | ||
@pipe_write.puts(msg) |
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 call can block if the pipe is full. My understanding is there needs to be a thread that is constantly reading the pipe to ensure the writing side doesn't block indefinitely.
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.
Have you considered https://ruby-doc.org/core-2.5.0/Queue.html ?
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.
I have, but Queue
is thread safe, and according to its docs "The Queue class implements all the required locking semantics." So, we may encounter the same problem with queue. I'll do some testing, though. If it works, I would prefer queue over pipe here.
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.
Changed to queue, seems to be safe.
d267a53
to
a1fb68e
Compare
I think it is more correct to use server addresses ( |
Good point, changed accordingly. |
Finalizers are called from signal trap, so mutexes do not work there (see https://github.com/ruby/ruby/blob/master/thread_sync.c#L288).