Merge pull request #20867 from yoshimaru46/fix-to-use-immutable-string-literal

Fix to use immutable string literal
pull/22749/head
apolcyn 5 years ago committed by GitHub
commit 6640651bcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      src/ruby/lib/grpc/generic/rpc_server.rb

@ -391,22 +391,21 @@ module GRPC
# register signal handlers
signals.each do |sig|
# input validation
if sig.class == String
sig.upcase!
if sig.start_with?('SIG')
# cut out the SIG prefix to see if valid signal
sig = sig[3..-1]
end
end
target_sig = if sig.class == String
# cut out the SIG prefix to see if valid signal
sig.upcase.start_with?('SIG') ? sig.upcase[3..-1] : sig.upcase
else
sig
end
# register signal traps for all valid signals
if valid_signals.value?(sig) || valid_signals.key?(sig)
Signal.trap(sig) do
if valid_signals.value?(target_sig) || valid_signals.key?(target_sig)
Signal.trap(target_sig) do
@stop_server = true
@stop_server_cv.broadcast
end
else
fail "#{sig} not a valid signal"
fail "#{target_sig} not a valid signal"
end
end

Loading…
Cancel
Save