Allow disable to fast_fallback of TCPSocket.new (#12210)

with `Socket.tcp_fast_fallback=`
The functions that `Socket.tcp` had are now also available in `TCPSocket.new`.
This commit is contained in:
Misaki Shioi 2024-11-29 14:18:09 +09:00 committed by GitHub
parent f9d0bc22f5
commit 22e1a8c478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-11-29 05:18:31 +00:00
Merged-By: shioimm <shioi.mm@gmail.com>

View File

@ -60,7 +60,7 @@ tcp_init(int argc, VALUE *argv, VALUE sock)
VALUE kwargs[4];
VALUE resolv_timeout = Qnil;
VALUE connect_timeout = Qnil;
VALUE fast_fallback = Qtrue;
VALUE fast_fallback = Qnil;
VALUE test_mode_settings = Qnil;
if (!keyword_ids[0]) {
@ -81,6 +81,13 @@ tcp_init(int argc, VALUE *argv, VALUE sock)
if (kwargs[3] != Qundef) { test_mode_settings = kwargs[3]; }
}
if (fast_fallback == Qnil) {
VALUE socket_class = rb_const_get(rb_cObject, rb_intern("Socket"));
ID var_id = rb_intern("@tcp_fast_fallback");
fast_fallback = rb_ivar_get(socket_class, var_id);
if (fast_fallback == Qnil) fast_fallback = Qtrue;
}
return rsock_init_inetsock(sock, remote_host, remote_serv,
local_host, local_serv, INET_CLIENT,
resolv_timeout, connect_timeout, fast_fallback,