From: Tobias Crawley <[email protected]> This patch is based off of Michal's "Dynamic driver selection using Rack middleware (rev 1)" patch from several days ago. His suspicions were correct - setting the driver via sinatra's 'set' mechanism is not thread safe (I tested it using [1], with a 'sleep(rand)' added to the /api method). I played with it a bit, and came up with a version that appears to be thread safe using Thread.current instead of sinatra's settings. I tested this using [1] with Deltacloud running under TorqueBox/JRuby and Thin.
[1] https://gist.github.com/722497 Tobias Crawley (1): Allow for dynamic driver selection via header, storing it in Thread.current. server/lib/drivers.rb | 97 +++++++++++++++------------- server/lib/sinatra/lazy_auth.rb | 2 +- server/lib/sinatra/rabbit.rb | 8 +- server/lib/sinatra/rack_driver_select.rb | 22 ++++++ server/server.rb | 41 ++++++++---- server/views/api/drivers.xml.haml | 6 ++ server/views/api/show.html.haml | 4 +- server/views/api/show.xml.haml | 2 +- server/views/errors/backend_error.xml.haml | 2 +- server/views/layout.html.haml | 2 +- 10 files changed, 117 insertions(+), 69 deletions(-) create mode 100644 server/lib/sinatra/rack_driver_select.rb create mode 100644 server/views/api/drivers.xml.haml -- 1.7.3.2
