Return-Path: Delivered-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Received: (qmail 73898 invoked from network); 30 Nov 2010 22:12:42 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Nov 2010 22:12:42 -0000 Received: (qmail 48787 invoked by uid 500); 30 Nov 2010 22:12:42 -0000 Delivered-To: apmail-incubator-deltacloud-dev-archive@incubator.apache.org Received: (qmail 48771 invoked by uid 500); 30 Nov 2010 22:12:42 -0000 Mailing-List: contact deltacloud-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-dev@incubator.apache.org Received: (qmail 48763 invoked by uid 99); 30 Nov 2010 22:12:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 22:12:41 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=10.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of tcrawley@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 22:12:35 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAUMCDm7029647 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 30 Nov 2010 17:12:13 -0500 Received: from katahdin.redhat.com (ovpn-113-116.phx2.redhat.com [10.3.113.116]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAUMCCF4025671 for ; Tue, 30 Nov 2010 17:12:12 -0500 From: tcrawley@redhat.com To: deltacloud-dev@incubator.apache.org Subject: [PATCH] Modified dynamic driver selection Date: Tue, 30 Nov 2010 17:12:10 -0500 Message-Id: <1291155131-28542-1-git-send-email-tcrawley@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Virus-Checked: Checked by ClamAV on apache.org From: Tobias Crawley 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