Skip to content

Commit 22e1a8c

Browse files
authored
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`.
1 parent f9d0bc2 commit 22e1a8c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ext/socket/tcpsocket.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ tcp_init(int argc, VALUE *argv, VALUE sock)
6060
VALUE kwargs[4];
6161
VALUE resolv_timeout = Qnil;
6262
VALUE connect_timeout = Qnil;
63-
VALUE fast_fallback = Qtrue;
63+
VALUE fast_fallback = Qnil;
6464
VALUE test_mode_settings = Qnil;
6565

6666
if (!keyword_ids[0]) {
@@ -81,6 +81,13 @@ tcp_init(int argc, VALUE *argv, VALUE sock)
8181
if (kwargs[3] != Qundef) { test_mode_settings = kwargs[3]; }
8282
}
8383

84+
if (fast_fallback == Qnil) {
85+
VALUE socket_class = rb_const_get(rb_cObject, rb_intern("Socket"));
86+
ID var_id = rb_intern("@tcp_fast_fallback");
87+
fast_fallback = rb_ivar_get(socket_class, var_id);
88+
if (fast_fallback == Qnil) fast_fallback = Qtrue;
89+
}
90+
8491
return rsock_init_inetsock(sock, remote_host, remote_serv,
8592
local_host, local_serv, INET_CLIENT,
8693
resolv_timeout, connect_timeout, fast_fallback,

0 commit comments

Comments
 (0)