Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit ddcc67115c8863d053f8286efe21db74e1678b44 1 parent 3c141e1
David Heinemeier Hansson dhh authored
2  actionpack/CHANGELOG
View
@@ -1,5 +1,7 @@
*SVN*
+* Added thread-safety to the DRbStore #66, #389 [Ben Stiglitz]
+
* Added DateHelper#select_time and DateHelper#select_second #373 [Scott Baron]
* Added class declaration for the MissingFile exception #388 [Kent Sibilev]
25 actionpack/lib/action_controller/session/drb_server.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.