[ruby/openssl] Reduce OpenSSL::Buffering#do_write overhead
[Bug #20972]
The rb_str_new_freeze was added in https://github.com/ruby/openssl/issues/452 to better handle concurrent use of a Socket, but SSL sockets can't be used concurrently AFAIK, so we might as well just error cleanly.
rb_str_new_freeze
By using rb_str_locktmp we can ensure attempts at concurrent write will raise an error, be we avoid causing a copy of the bytes.
rb_str_locktmp
We also use the newer String#append_as_bytes method when available to save on some more copies.
String#append_as_bytes
https://github.com/ruby/openssl/commit/0d8c17aa85
Co-Authored-By: [email protected]
[ruby/openssl] Reduce OpenSSL::Buffering#do_write overhead
[Bug #20972]
The
rb_str_new_freeze
was added in https://github.com/ruby/openssl/issues/452to better handle concurrent use of a Socket, but SSL sockets can't be used
concurrently AFAIK, so we might as well just error cleanly.
By using
rb_str_locktmp
we can ensure attempts at concurrent writewill raise an error, be we avoid causing a copy of the bytes.
We also use the newer
String#append_as_bytes
method when availableto save on some more copies.
https://github.com/ruby/openssl/commit/0d8c17aa85
Co-Authored-By: [email protected]