diff options
-rw-r--r-- | lib/rubygems/gemcutter_utilities/webauthn_listener.rb | 13 | ||||
-rw-r--r-- | lib/rubygems/gemcutter_utilities/webauthn_poller.rb | 13 |
2 files changed, 12 insertions, 14 deletions
diff --git a/lib/rubygems/gemcutter_utilities/webauthn_listener.rb b/lib/rubygems/gemcutter_utilities/webauthn_listener.rb index ee3fc7bcab..bea9d9e397 100644 --- a/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +++ b/lib/rubygems/gemcutter_utilities/webauthn_listener.rb @@ -33,17 +33,16 @@ module Gem::GemcutterUtilities end def self.listener_thread(host, server) - thread = Thread.new do - Thread.current[:otp] = new(host).wait_for_otp_code(server) + Thread.new do + thread = Thread.current + thread.abort_on_exception = true + thread.report_on_exception = false + thread[:otp] = new(host).wait_for_otp_code(server) rescue Gem::WebauthnVerificationError => e - Thread.current[:error] = e + thread[:error] = e ensure server.close end - thread.abort_on_exception = true - thread.report_on_exception = false - - thread end def wait_for_otp_code(server) diff --git a/lib/rubygems/gemcutter_utilities/webauthn_poller.rb b/lib/rubygems/gemcutter_utilities/webauthn_poller.rb index 766b38584e..e7068605a4 100644 --- a/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +++ b/lib/rubygems/gemcutter_utilities/webauthn_poller.rb @@ -32,15 +32,14 @@ module Gem::GemcutterUtilities end def self.poll_thread(options, host, webauthn_url, credentials) - thread = Thread.new do - Thread.current[:otp] = new(options, host).poll_for_otp(webauthn_url, credentials) + Thread.new do + thread = Thread.current + thread.abort_on_exception = true + thread.report_on_exception = false + thread[:otp] = new(options, host).poll_for_otp(webauthn_url, credentials) rescue Gem::WebauthnVerificationError, Timeout::Error => e - Thread.current[:error] = e + thread[:error] = e end - thread.abort_on_exception = true - thread.report_on_exception = false - - thread end def poll_for_otp(webauthn_url, credentials) |