1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

perhaps make more threadsafe

This commit is contained in:
Kevin Olbrich 2014-01-02 21:14:40 +00:00
parent 26cb64e9ce
commit 467dd39281

View file

@ -1,5 +1,6 @@
require 'fog/joyent' require 'fog/joyent'
require 'fog/joyent/errors' require 'fog/joyent/errors'
require 'thread'
module Fog module Fog
module Joyent module Joyent
@ -60,6 +61,7 @@ module Fog
def initialize(options = {}) def initialize(options = {})
@joyent_username = options[:joyent_username] || Fog.credentials[:joyent_username] @joyent_username = options[:joyent_username] || Fog.credentials[:joyent_username]
@joyent_password = options[:joyent_password] || Fog.credentials[:joyent_password] @joyent_password = options[:joyent_password] || Fog.credentials[:joyent_password]
@mutex = Mutex.new
end end
def request(opts) def request(opts)
@ -161,8 +163,10 @@ module Fog
date = Time.now.utc.httpdate date = Time.now.utc.httpdate
# Force KeyManager to load the key(s) # Force KeyManager to load the key(s)
@key_manager.each_identity {} @mutex.synchronize do
@key_manager.each_identity {}
end
key = @key_manager.known_identities.keys.first key = @key_manager.known_identities.keys.first
sig = if key.kind_of? OpenSSL::PKey::RSA sig = if key.kind_of? OpenSSL::PKey::RSA