Skip to content

Commit 10d5a65

Browse files
kpumukJens-G
authored andcommitted
ruby: Set TCP_NODELAY on accepted sockets
1 parent 120d496 commit 10d5a65

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

lib/rb/lib/thrift/transport/server_socket.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def listen
4343
def accept
4444
unless @handle.nil?
4545
sock = @handle.accept
46+
sock.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
4647
trans = Socket.new
4748
trans.handle = sock
4849
trans

lib/rb/spec/server_socket_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
expect(TCPServer).to receive(:new).with(nil, 1234).and_return(handle)
4545
@socket.listen
4646
sock = double("sock")
47+
expect(sock).to receive(:setsockopt).with(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
4748
expect(handle).to receive(:accept).and_return(sock)
4849
trans = double("Socket")
4950
expect(Thrift::Socket).to receive(:new).and_return(trans)

0 commit comments

Comments
 (0)