Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/trunk/actionpack/lib/action_controller/session/drb_server.rb

Revision 315, 0.7 kB (checked in by david, 4 years ago)

Added thread-safety to the DRbStore #66, #389 [Ben Stiglitz]

Line 
1 #!/usr/local/bin/ruby -w
2                                                                                
3 # This is a really simple session storage daemon, basically just a hash,
4 # which is enabled for DRb access.
5                                                                                
6 require 'drb'
7
8 session_hash = Hash.new
9 session_hash.instance_eval { @mutex = Mutex.new }
10
11 class <<session_hash
12   def []=(key, value)
13     @mutex.synchronize do
14       super(key, value)
15     end
16   end
17  
18   def [](key)
19     @mutex.synchronize do
20       super(key)
21     end
22   end
23  
24   def delete(key)
25     @mutex.synchronize do
26       super(key)
27     end
28   end
29 end
30
31 DRb.start_service('druby://127.0.0.1:9192', session_hash)
32 DRb.thread.join
Note: See TracBrowser for help on using the browser.