diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-07-29 10:21:55 +0900 |
---|---|---|
committer | git <[email protected]> | 2023-07-30 01:37:43 +0000 |
commit | 67be453d9d1e94b104ba2f092d89c33efac2a2e2 (patch) | |
tree | aa75d0ad7918f2da5f29a927bca1855773239c4e | |
parent | 0d86cc4caf1495507b2937654d3ed868278b9ddc (diff) |
[rubygems/rubygems] Set thread configurations inside block in the thread local manner
https://github.com/rubygems/rubygems/commit/965e54b8f1
-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) |