diff options
author | Misaki Shioi <[email protected]> | 2024-11-29 14:18:09 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2024-11-29 14:18:09 +0900 |
commit | 22e1a8c478e92fafcb597d74a2d4f08c57f07c4c (patch) | |
tree | 3838a1afda426451ab21ebe109ef7dc751841143 /ext/socket | |
parent | f9d0bc22f5ca019f3c517b42ea4a50867fe56700 (diff) |
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`.
Notes
Notes:
Merged-By: shioimm <[email protected]>
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/tcpsocket.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/socket/tcpsocket.c b/ext/socket/tcpsocket.c index 3c03e89e0d..e091d75e5d 100644 --- a/ext/socket/tcpsocket.c +++ b/ext/socket/tcpsocket.c @@ -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, |