Skip Menu |

This queue is for tickets about the Cache-FastMmap CPAN distribution.

Report information
The Basics
Id: 32252
Status: resolved
Priority: 0/
Queue: Cache-FastMmap

People
Owner: Nobody in particular
Requestors: jasonk [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.24
Fixed in: (no value)



Subject: share_file doesn't behave well if given an object (like Path::Class::File...)
Ran into a strange and difficult-to-find problem today. If Cache::FastMmap is given an object for it's share_file parameter, say something like this: my $cache = Cache::FastMmap->new( share_file => Path::Class::File->new( 'cache.mmap' ), ); It doesn't complain about it, instead it just creates an inexplicably-named file in the current directory (in my case part of the problem was that the file getting created was always named the same as if I had done share_file => "\cC"). Cache::FastMmap should probably either croak if given an object, or try and stringify it and use that. If stringified, even if the object didn't stringify to a filename, it might at least end up being something useful instead of some of the bizarre filenames it gets now which consist mostly of non-printable characters. Attached is a trivial patch which stringifies the value passed to share_file.
Subject: Cache-FastMmap.patch
--- Cache/FastMmap.pm 2007-10-21 23:14:16.000000000 -0400 +++ Cache/FastMmap.pm 2008-01-11 11:07:26.000000000 -0500 @@ -467,8 +467,8 @@ $share_file = ($^O eq "MSWin32" ? "c:\\sharefile" : "/tmp/sharefile"); $share_file .= "-" . $$ . "-" . time; } - $Self->{share_file} = $share_file; - + $Self->{share_file} = "$share_file"; # stringify in case it's an object, + # ala Path::Class my $init_file = $Args{init_file} || 0; my $test_file = $Args{test_file} || 0;
I've just uploaded 1.25 which should detect if you pass share_file as a reference and die. I'd prefer to just not accept references rather than stringifying them because it'll catch other cases of accidentally passing a hash-ref or array-ref, which would still be stringified into something bad like "ARRAY(x12345678)". You should stringify it yourself before passing in.