forked from sunspot/sunspot
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly namespace thread-local session instances
Previously I was storing the session wrapped by a ThreadLocalSessionProxy in a static thread-local session variable, :sunspot_session. This of course meant that two ThreadLocalSessionProxy instances would share the same underlying Session instance in a given thread, which is not the expected or desired behavior (e.g., when two TLSPs are encapsulated by a MasterSlaveSessionProxy). Now the underlying session is stored in a thread-local variable which includes the proxy's object_id, thus scoping each session to its owning proxy. A finalizer is used to ensure that the session instances don't remain in the thread-local namespace after the proxy instance is garbage collected (a concern if threads are long-lived but proxies are short-lived; granted an unlikely use case in reality, but due diligence never hurts). [sunspot#103 state:resolved]
- Loading branch information
Mat Brown
committed
Mar 29, 2010
1 parent
ba562c4
commit 45048d0
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters