Skip Menu |

This queue is for tickets about the Apache-Session CPAN distribution.

Report information
The Basics
Id: 56727
Status: resolved
Priority: 0/
Queue: Apache-Session

People
Owner: Nobody in particular
Requestors: ianburrell [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.88
Fixed in: 1.89



Subject: Apache::Session::Store::File does not flush buffers which can lead to corrupt sessions
We are getting errors like "Session could not be unserialized at /usr/local/stow/perl-5.8.8/lib/perl5/site_perl/5.8.8/Apache/Session/Serialize/Storable.pm line 28" when two processes accessed the same session. What was happening is that the second process was reading a partial 49152 byte file when the first process had written a 53307 byte serialized file. Once the first process finished, the file would be its full size. I am guessing that the 48K is a buffer size and that some of the serialized value is buffered in the first process. Adding a flush after the print fixes the problem. I used the IO::Handle flush() method. It would also work to enable autoflush() on the handle.
From: ianburrell [...] gmail.com
Here is a patch which adds a flush after each print. It adds IO::File to get the flush method.
Subject: file_flush.patch
# HG changeset patch # User Ian Burrell <imb@rentrak.com> # Date 1271711675 25200 # Node ID 28db5f1cddc3bffae8d986ef6009f45a303ddff5 # Parent 52f1b4f7bd640e1b042a979531466ac8ae906afe Add flush to insert and update to fix buffering corruption diff -r 52f1b4f7bd64 -r 28db5f1cddc3 Session/Store/File.pm --- a/Session/Store/File.pm Mon Apr 19 14:11:10 2010 -0700 +++ b/Session/Store/File.pm Mon Apr 19 14:14:35 2010 -0700 @@ -10,6 +10,7 @@ package Apache::Session::Store::File; use strict; +use IO::File; use Symbol; use Fcntl; use vars qw($VERSION); @@ -45,6 +46,7 @@ $self->{opened} = 1; print {$self->{fh}} $session->{serialized}; + $self->{fh}->flush(); } sub update { @@ -64,6 +66,7 @@ truncate($self->{fh}, 0) || die "Could not truncate file: $!"; seek($self->{fh}, 0, 0); print {$self->{fh}} $session->{serialized}; + $self->{fh}->flush(); } sub materialize {
All 3 your patches are added to repository. New version will be released soon. -- Alexandr Ciornii, http://chorny.net