0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-04 10:39:43 +08:00
discourse/lib/freedom_patches/pitchfork_sock_stream.rb
2026-05-13 18:37:09 +02:00

22 lines
649 B
Ruby
Vendored

# frozen_string_literal: true
return unless defined?(Pitchfork::HttpServer)
# Pitchfork's monitor wakeup is a single-byte NOOP ("."). Coalesced reads
# like "..." aren't recognized and get logged as unexpected — treat any
# all-dots read as a NOOP.
module PitchforkSockStreamPatch
def monitor_sleep(sec)
@control_socket[0].wait(sec) or return
case message = @control_socket[0].recvmsg_nonblock(exception: false)
when :wait_readable
nil
when String
@sig_queue << message unless message.match?(/\A\.+\z/)
else
@sig_queue << message
end
end
end
Pitchfork::HttpServer.prepend(PitchforkSockStreamPatch)