Skip to content

Commit 04f6e8e

Browse files
author
Reini Urban
committed
Storable 3.00: u64 strings, arrays and hashes >2G
via a new LOBJECT tag. This is for 32bit systems and lengths between 2GB and 4GB (I32-U32), and 64bit (>I32). Use SSize_t array and hash lengths, see [cperl #123]. Even for hashes, which we cannot iterate over. This is a upstream limitation in the HvAUX struct and API. We can store >2G keys though, which is fully supported in subsequent cperl commits for #123, but not perl5 upstream. Add several helper functions for strings and hash entries, removed a lot of duplicate code. Reformat consistently (tabs: 8) Modernize: * get rid of main'dump * get rid of *FILE typeglob, replace with lexical filehandle * fix parallel tests, use unique filenames. * fixed many instances of 2arg open, * keep backcompat default handling for XS functions, handle the flag default there. * remove default $Storable::flags settings in the tests * fix some too short I32 len types in the XS
1 parent c6f7713 commit 04f6e8e

20 files changed

+1816
-1442
lines changed

ChangeLog

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
Thu Mar 31 17:10:27 2016 +0200 Reini Urban <[email protected]>
2+
Version 3.00c
3+
4+
* Added support for u64 strings, arrays and hashes >2G
5+
via a new LOBJECT tag. This is for 32bit systems and lengths
6+
between 2GB and 4GB (I32-U32), and 64bit (>I32).
7+
* Bumped STORABLE_BIN_MINOR and STORABLE_BIN_WRITE_MINOR from 10 to 11
8+
* fix parallel tests, use unique filenames.
9+
* fixed 2 instances of 2arg open,
10+
* added optional flag arguments to skip tie and bless on retrieve/thaw,
11+
* added SECURITY WARNING and Large data support to docs
12+
* compute CAN_FLOCK at compile-time
13+
* reformat everything consistently
14+
* enable DEBUGME tracing and asserts with -DDEBUGGING
15+
* fix all 64 bit compiler warnings
16+
* added some abstraction methods to avoid code duplication
17+
118
Wed Jul 2 16:25:25 IST 2014 Abhijit Menon-Sen <[email protected]>
219
Version 2.51
320

README

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
Storable 2.14
1+
Storable 3.00
22
Copyright (c) 1995-2000, Raphael Manfredi
33
Copyright (c) 2001-2004, Larry Wall
4+
Copyright (c) 2016, cPanel Inc
45

56
------------------------------------------------------------------------
67
This program is free software; you can redistribute it and/or modify
@@ -15,8 +16,8 @@
1516
+=======================================================================
1617
| Storable is distributed as a module, but is also part of the official
1718
| Perl core distribution, as of perl 5.8.
18-
| Maintenance is now done by the perl5-porters. We thank Raphael
19-
| Manfredi for providing us with this very useful module.
19+
| Maintenance is partially done by the perl5-porters, and for cperl by cPanel.
20+
| We thank Raphael Manfredi for providing us with this very useful module.
2021
+=======================================================================
2122

2223
The Storable extension brings persistence to your data.
@@ -68,6 +69,9 @@ Thanks to (in chronological order):
6869
Marc Lehmann <[email protected]>
6970
Justin Banks <[email protected]>
7071
Jarkko Hietaniemi <[email protected]> (AGAIN, as perl 5.7.0 Pumpkin!)
72+
Todd Rinaldo <[email protected]>, JD Lightsey <[email protected]>
73+
for optional disabling tie and bless for increased security
74+
Reini Urban <[email protected]> for the 3.00 >2G support and rewrite
7175

7276
for their contributions.
7377

Storable.pm

+17-23
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ package Storable; @ISA = qw(Exporter);
2424

2525
use vars qw($canonical $forgive_me $VERSION);
2626

27-
$VERSION = '2.57_01';
27+
$VERSION = '3.00c';
28+
$VERSION =~ s/c$//;
29+
$VERSION = eval $VERSION;
2830

2931
BEGIN {
3032
if (eval { local $SIG{__DIE__}; require Log::Agent; 1 }) {
@@ -68,21 +70,13 @@ sub CLONE {
6870
Storable::init_perinterp();
6971
}
7072

71-
sub BLESS_OK {
72-
return 2;
73-
}
74-
75-
sub TIE_OK {
76-
return 4;
77-
}
78-
79-
sub FLAGS_COMPAT {
80-
return BLESS_OK | TIE_OK;
81-
}
73+
sub BLESS_OK () { 2 }
74+
sub TIE_OK () { 4 }
75+
sub FLAGS_COMPAT () { BLESS_OK | TIE_OK }
8276

8377
# By default restricted hashes are downgraded on earlier perls.
8478

85-
$Storable::flags = 6;
79+
$Storable::flags = FLAGS_COMPAT;
8680
$Storable::downgrade_restricted = 1;
8781
$Storable::accept_future_minor = 1;
8882

@@ -129,7 +123,7 @@ sub file_magic {
129123

130124
my $file = shift;
131125
my $fh = IO::File->new;
132-
open($fh, "<". $file) || die "Can't open '$file': $!";
126+
open($fh, "<", $file) || die "Can't open '$file': $!";
133127
binmode($fh);
134128
defined(sysread($fh, my $buf, 32)) || die "Can't read from '$file': $!";
135129
close($fh);
@@ -372,7 +366,7 @@ sub _freeze {
372366
# will be blessed nor tied.
373367
#
374368
sub retrieve {
375-
_retrieve($_[0], $_[1], 0);
369+
_retrieve(shift, 0, @_);
376370
}
377371

378372
#
@@ -381,16 +375,16 @@ sub retrieve {
381375
# Same as retrieve, but with advisory locking.
382376
#
383377
sub lock_retrieve {
384-
_retrieve($_[0], $_[1], 1);
378+
_retrieve(shift, 1, @_);
385379
}
386380

387381
# Internal retrieve routine
388382
sub _retrieve {
389-
my ($file, $flags, $use_locking) = @_;
383+
my ($file, $use_locking, $flags) = @_;
390384
$flags = $Storable::flags unless defined $flags;
391-
local *FILE;
392-
open(FILE, "<", $file) || logcroak "can't open $file: $!";
393-
binmode FILE; # Archaic systems...
385+
my $FILE;
386+
open($FILE, "<", $file) || logcroak "can't open $file: $!";
387+
binmode $FILE; # Archaic systems...
394388
my $self;
395389
my $da = $@; # Could be from exception handler
396390
if ($use_locking) {
@@ -399,11 +393,11 @@ sub _retrieve {
399393
"Storable::lock_store: fcntl/flock emulation broken on $^O";
400394
return undef;
401395
}
402-
flock(FILE, LOCK_SH) || logcroak "can't get shared lock on $file: $!";
396+
flock($FILE, LOCK_SH) || logcroak "can't get shared lock on $file: $!";
403397
# Unlocking will happen when FILE is closed
404398
}
405-
eval { $self = pretrieve(*FILE, $flags) }; # Call C routine
406-
close(FILE);
399+
eval { $self = pretrieve($FILE, $flags) }; # Call C routine
400+
close($FILE);
407401
logcroak $@ if $@ =~ s/\.?\n$/,/;
408402
$@ = $da;
409403
return $self;

0 commit comments

Comments
 (0)