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
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 693
Download (untitled) / with headers
text/plain 693b
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.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1271711816-26545-404"
Message-ID: <rt-3.8.HEAD-26545-1271711816-197.56727-0-0 [...] rt.cpan.org>
From: ianburrell [...] gmail.com
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 96
Here is a patch which adds a flush after each print. It adds IO::File to get the flush method.
MIME-Version: 1.0
Subject: file_flush.patch
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: application/octet-stream; name="file_flush.patch"
Content-Disposition: inline; filename="file_flush.patch"
Content-Transfer-Encoding: base64
Content-Length: 918
Download file_flush.patch
text/x-diff 918b
# 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 {
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-24877-1285109206-787.56727-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 120
Download (untitled) / with headers
text/plain 120b
All 3 your patches are added to repository. New version will be released soon. -- Alexandr Ciornii, http://chorny.net


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.