Skip to content

Commit

Permalink
Fix: patch Puma around a JRuby ARM64 bug (elastic#13447)
Browse files Browse the repository at this point in the history
Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
  • Loading branch information
kares and jsvd authored Nov 25, 2021
1 parent 2788e87 commit 32690cb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions logstash-core/lib/logstash/patches/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,19 @@ module Puma
STDERR = LogStash::IOWrappedLogger.new(LogStash::NullLogger)
STDOUT = LogStash::IOWrappedLogger.new(LogStash::NullLogger)
end

# JRuby (>= 9.2.18.0) added support for getsockopt(Socket::IPPROTO_TCP, Socket::TCP_INFO)
# however it isn't working correctly on ARM64 likely due an underlying issue in JNR/JFFI.
#
# Puma uses the TCP_INFO to detect a closed socket when handling a request and has a dummy
# fallback in place when Socket constants :TCP_INFO && :IPPROTO_TCP are not defined, see:
# https://github.com/puma/puma/blob/v5.5.2/lib/puma/server.rb#L169-L192
#
# Remove this patch once https://github.com/elastic/logstash/issues/13444 gets resolved!
if ENV_JAVA['os.name'].match?(/Linux/i) && ENV_JAVA['os.arch'].eql?('aarch64')
Puma::Server.class_eval do
def closed_socket?(socket)
false
end
end
end

0 comments on commit 32690cb

Please sign in to comment.