aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/session/drb_server.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-02 16:00:50 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-02 16:00:50 +0000
commitddcc67115c8863d053f8286efe21db74e1678b44 (patch)
treeee6e88881796ad054f511c768678052dbdb365ed /actionpack/lib/action_controller/session/drb_server.rb
parent3c141e12fc8b7c2e02ac05449a80a409f415d49c (diff)
downloadrails-ddcc67115c8863d053f8286efe21db74e1678b44.tar.gz
rails-ddcc67115c8863d053f8286efe21db74e1678b44.tar.bz2
rails-ddcc67115c8863d053f8286efe21db74e1678b44.zip
Added thread-safety to the DRbStore #66, #389 [Ben Stiglitz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@315 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/session/drb_server.rb')
-rw-r--r--actionpack/lib/action_controller/session/drb_server.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/session/drb_server.rb b/actionpack/lib/action_controller/session/drb_server.rb
index 6005b8b2b3..6f90db6747 100644
--- a/actionpack/lib/action_controller/session/drb_server.rb
+++ b/actionpack/lib/action_controller/session/drb_server.rb
@@ -5,5 +5,28 @@
require 'drb'
-DRb.start_service('druby://127.0.0.1:9192', Hash.new)
+session_hash = Hash.new
+session_hash.instance_eval { @mutex = Mutex.new }
+
+class <<session_hash
+ def []=(key, value)
+ @mutex.synchronize do
+ super(key, value)
+ end
+ end
+
+ def [](key)
+ @mutex.synchronize do
+ super(key)
+ end
+ end
+
+ def delete(key)
+ @mutex.synchronize do
+ super(key)
+ end
+ end
+end
+
+DRb.start_service('druby://127.0.0.1:9192', session_hash)
DRb.thread.join \ No newline at end of file