bcrypt-ruby / bcrypt-ruby

bcrypt-ruby is a Ruby binding for the OpenBSD bcrypt() password hashing algorithm, allowing you to easily store a secure hash of your users' passwords.
Other
1.92k stars 282 forks source link

Make C-extension Ractor-safe #278

Open mohamedhafez opened 3 months ago

mohamedhafez commented 3 months ago

In planning ahead to the near future when TruffleRuby can run C-extensions marked with rb_ext_ractor_safe(true) in parallel, and for when Ractors are no longer just experimental, it would be great if the C-extension could be made Ractor-safe, or marked as such if it already is so!

eregon commented 1 month ago

I took a look at https://github.com/bcrypt-ruby/bcrypt-ruby/blob/master/ext/mri/bcrypt_ext.c. The only global variables there are assigned once during the Init_ function, so there is simply no global state. So that seems safe to mark as Ractor-safe.

Docs about rb_ext_ractor_safe: https://github.com/ruby/ruby/blob/master/doc/extension.rdoc#appendix-f-ractor-support-