Workaround for Cache::FastMmap limitation in Session
Yuval Kogman [Wed, 28 Dec 2005 11:14:30 +0000 (11:14 +0000)]
Changes
lib/Catalyst/Plugin/Session.pm

diff --git a/Changes b/Changes
index f10f2a8..2216bc3 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,10 @@
 Revision history for Perl extension Catalyst::Plugin::Session
 
-0.03
+0.04    2005-12-28 09:42:00
+        - Work around a limitation in Cache::FastMmap - must store only
+          references, while expiration was an NV.
+
+0.03    2005-12-26 10:22:00
         - Lazify loading of session data for better performance and less chance
           of race conditions
         - support for $c->flash a la Ruby on Rails
index 9f7eede..db5f7c6 100644 (file)
@@ -98,8 +98,12 @@ sub _save_session {
 
             # all sessions are extended at the end of the request
             my $now = time;
-            $c->store_session_data(
-                "expires:$sid" => ( $c->config->{session}{expires} + $now ) );
+
+            # the ref is a workaround for FastMmap:
+            # FastMmap can't store values which aren't refs
+            # this yields errors and other great suckage
+            $c->store_session_data( "expires:$sid" =>
+                  ( { expires => $c->config->{session}{expires} + $now } ) );
 
             no warnings 'uninitialized';
             if ( Object::Signature::signature($session_data) ne
@@ -135,7 +139,10 @@ sub _load_session {
     if ( my $sid = $c->_sessionid ) {
         no warnings 'uninitialized';    # ne __address
 
-        my $session_expires = $c->get_session_data("expires:$sid") || 0;
+        # see above for explanation  of the workaround for FastMmap problem
+        my $session_expires =
+          ( $c->get_session_data("expires:$sid") || { expires => 0 } )
+          ->{expires};
 
         if ( $session_expires < time ) {