Skip to content

Commit ec0d329

Browse files
author
Bartosz Oudekerk
committed
Replace POSIX::tzset with DateTime::TimeZone for cross-platform alarm scheduling
POSIX::tzset with $ENV{TZ} does not work on Windows, where Perl requires Windows-native timezone names rather than Olson identifiers. This made alarm scheduling in a player's timezone silently fall back to the server timezone on Windows. Replace with DateTime::TimeZone, which uses a bundled IANA timezone database and works identically on all platforms. - Add Slim::Utils::DateTime::localtimeInTZ($epoch, $tzName), a thin wrapper around DateTime::TimeZone that returns a localtime()-style list in the named Olson timezone, with a per-process cache and a graceful fallback to server timezone for unrecognised names - Use localtimeInTZ in Slim::Utils::Alarm::findNextTime and Slim::Plugin::Rescan::Plugin::checkScanTimer, replacing the POSIX::tzset save/restore blocks - Bundle DateTime::TimeZone 2.66 (IANA tzdata 2025c) and its dependencies in CPAN/ Signed-off-by: Bartosz Oudekerk <lot+github@unreachablehost.net>
1 parent 339b1db commit ec0d329

File tree

411 files changed

+272717
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

411 files changed

+272717
-18
lines changed

CPAN/B/Hooks/EndOfScope.pm

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
package B::Hooks::EndOfScope; # git description: 0.27-8-gbe15c53
2+
# ABSTRACT: Execute code after a scope finished compilation
3+
# KEYWORDS: code hooks execution scope
4+
5+
use strict;
6+
use warnings;
7+
8+
our $VERSION = '0.28';
9+
10+
use 5.006001;
11+
12+
BEGIN {
13+
use Module::Implementation 0.05;
14+
Module::Implementation::build_loader_sub(
15+
implementations => [ 'XS', 'PP' ],
16+
symbols => [ 'on_scope_end' ],
17+
)->();
18+
}
19+
20+
use Sub::Exporter::Progressive 0.001006 -setup => {
21+
exports => [ 'on_scope_end' ],
22+
groups => { default => ['on_scope_end'] },
23+
};
24+
25+
1;
26+
27+
__END__
28+
29+
=pod
30+
31+
=encoding UTF-8
32+
33+
=head1 NAME
34+
35+
B::Hooks::EndOfScope - Execute code after a scope finished compilation
36+
37+
=head1 VERSION
38+
39+
version 0.28
40+
41+
=head1 SYNOPSIS
42+
43+
on_scope_end { ... };
44+
45+
=head1 DESCRIPTION
46+
47+
This module allows you to execute code when perl finished compiling the
48+
surrounding scope.
49+
50+
=head1 FUNCTIONS
51+
52+
=head2 on_scope_end
53+
54+
on_scope_end { ... };
55+
56+
on_scope_end $code;
57+
58+
Registers C<$code> to be executed after the surrounding scope has been
59+
compiled.
60+
61+
This is exported by default. See L<Sub::Exporter> on how to customize it.
62+
63+
=head1 LIMITATIONS
64+
65+
=head2 Pure-perl mode caveat
66+
67+
This caveat applies to B<any> version of perl where L<Variable::Magic>
68+
is unavailable or otherwise disabled.
69+
70+
While L<Variable::Magic> has access to some very dark sorcery to make it
71+
possible to throw an exception from within a callback, the pure-perl
72+
implementation does not have access to these hacks. Therefore, what
73+
would have been a B<compile-time exception> is instead B<converted to a
74+
warning>, and your execution will continue as if the exception never
75+
happened.
76+
77+
To explicitly request an XS (or PP) implementation one has two choices. Either
78+
to import from the desired implementation explicitly:
79+
80+
use B::Hooks::EndOfScope::XS
81+
or
82+
use B::Hooks::EndOfScope::PP
83+
84+
or by setting C<$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION}> to either C<XS> or
85+
C<PP>.
86+
87+
=head2 Perl 5.8.0 ~ 5.8.3
88+
89+
Due to a L<core interpreter bug
90+
|https://rt.perl.org/Public/Bug/Display.html?id=27040#txn-82797> present in
91+
older perl versions, the implementation of B::Hooks::EndOfScope deliberately
92+
leaks a single empty hash for every scope being cleaned. This is done to
93+
avoid the memory corruption associated with the bug mentioned above.
94+
95+
In order to stabilize this workaround use of L<Variable::Magic> is disabled
96+
on perls prior to version 5.8.4. On such systems loading/requesting
97+
L<B::Hooks::EndOfScope::XS> explicitly will result in a compile-time
98+
exception.
99+
100+
=head2 Perl versions 5.6.x
101+
102+
Versions of perl before 5.8.0 lack a feature allowing changing the visibility
103+
of C<%^H> via setting bit 17 within C<$^H>. As such the only way to achieve
104+
the effect necessary for this module to work, is to use the C<local> operator
105+
explicitly on these platforms. This might lead to unexpected interference
106+
with other scope-driven libraries relying on the same mechanism. On the flip
107+
side there are no such known incompatibilities at the time this note was
108+
written.
109+
110+
For further details on the unavailable behavior please refer to the test
111+
file F<t/02-localise.t> included with the distribution.
112+
113+
=head1 SEE ALSO
114+
115+
L<Sub::Exporter>
116+
117+
L<Variable::Magic>
118+
119+
=head1 SUPPORT
120+
121+
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=B-Hooks-EndOfScope>
122+
(or L<bug-B-Hooks-EndOfScope@rt.cpan.org|mailto:bug-B-Hooks-EndOfScope@rt.cpan.org>).
123+
124+
=head1 AUTHORS
125+
126+
=over 4
127+
128+
=item *
129+
130+
Florian Ragwitz <rafl@debian.org>
131+
132+
=item *
133+
134+
Peter Rabbitson <ribasushi@leporine.io>
135+
136+
=back
137+
138+
=head1 CONTRIBUTORS
139+
140+
=for stopwords Karen Etheridge Graham Knop Christian Walde Simon Wilper Tatsuhiko Miyagawa Tomas Doran
141+
142+
=over 4
143+
144+
=item *
145+
146+
Karen Etheridge <ether@cpan.org>
147+
148+
=item *
149+
150+
Graham Knop <haarg@haarg.org>
151+
152+
=item *
153+
154+
Christian Walde <walde.christian@googlemail.com>
155+
156+
=item *
157+
158+
Simon Wilper <sxw@chronowerks.de>
159+
160+
=item *
161+
162+
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
163+
164+
=item *
165+
166+
Tomas Doran <bobtfish@bobtfish.net>
167+
168+
=back
169+
170+
=head1 COPYRIGHT AND LICENCE
171+
172+
This software is copyright (c) 2008 by Florian Ragwitz.
173+
174+
This is free software; you can redistribute it and/or modify it under
175+
the same terms as the Perl 5 programming language system itself.
176+
177+
=cut

CPAN/B/Hooks/EndOfScope/PP.pm

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package B::Hooks::EndOfScope::PP;
2+
# ABSTRACT: Execute code after a scope finished compilation - PP implementation
3+
4+
use warnings;
5+
use strict;
6+
7+
our $VERSION = '0.28';
8+
9+
use constant _PERL_VERSION => "$]";
10+
11+
BEGIN {
12+
if (_PERL_VERSION =~ /^5\.009/) {
13+
# CBA to figure out where %^H got broken and which H::U::HH is sane enough
14+
die "By design B::Hooks::EndOfScope does not operate in pure-perl mode on perl 5.9.X\n"
15+
}
16+
elsif (_PERL_VERSION < '5.010') {
17+
require B::Hooks::EndOfScope::PP::HintHash;
18+
*on_scope_end = \&B::Hooks::EndOfScope::PP::HintHash::on_scope_end;
19+
}
20+
else {
21+
require B::Hooks::EndOfScope::PP::FieldHash;
22+
*on_scope_end = \&B::Hooks::EndOfScope::PP::FieldHash::on_scope_end;
23+
}
24+
}
25+
26+
use Sub::Exporter::Progressive 0.001006 -setup => {
27+
exports => ['on_scope_end'],
28+
groups => { default => ['on_scope_end'] },
29+
};
30+
31+
sub __invoke_callback {
32+
local $@;
33+
eval { $_[0]->(); 1 } or do {
34+
my $err = $@;
35+
require Carp;
36+
Carp::cluck( (join ' ',
37+
'A scope-end callback raised an exception, which can not be propagated when',
38+
'B::Hooks::EndOfScope operates in pure-perl mode. Your program will CONTINUE',
39+
'EXECUTION AS IF NOTHING HAPPENED AFTER THIS WARNING. Below is the complete',
40+
'exception text, followed by a stack-trace of the callback execution:',
41+
) . "\n\n$err\n\r" );
42+
43+
sleep 1 if -t *STDERR; # maybe a bad idea...?
44+
};
45+
}
46+
47+
1;
48+
49+
__END__
50+
51+
=pod
52+
53+
=encoding UTF-8
54+
55+
=head1 NAME
56+
57+
B::Hooks::EndOfScope::PP - Execute code after a scope finished compilation - PP implementation
58+
59+
=head1 VERSION
60+
61+
version 0.28
62+
63+
=head1 DESCRIPTION
64+
65+
This is the pure-perl implementation of L<B::Hooks::EndOfScope> based only on
66+
modules available as part of the perl core. Its leaner sibling
67+
L<B::Hooks::EndOfScope::XS> will be automatically preferred if all
68+
dependencies are available and C<$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION}> is
69+
not set to C<'PP'>.
70+
71+
=head1 FUNCTIONS
72+
73+
=head2 on_scope_end
74+
75+
on_scope_end { ... };
76+
77+
on_scope_end $code;
78+
79+
Registers C<$code> to be executed after the surrounding scope has been
80+
compiled.
81+
82+
This is exported by default. See L<Sub::Exporter> on how to customize it.
83+
84+
=head1 SUPPORT
85+
86+
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=B-Hooks-EndOfScope>
87+
(or L<bug-B-Hooks-EndOfScope@rt.cpan.org|mailto:bug-B-Hooks-EndOfScope@rt.cpan.org>).
88+
89+
=head1 AUTHORS
90+
91+
=over 4
92+
93+
=item *
94+
95+
Florian Ragwitz <rafl@debian.org>
96+
97+
=item *
98+
99+
Peter Rabbitson <ribasushi@leporine.io>
100+
101+
=back
102+
103+
=head1 COPYRIGHT AND LICENCE
104+
105+
This software is copyright (c) 2008 by Florian Ragwitz.
106+
107+
This is free software; you can redistribute it and/or modify it under
108+
the same terms as the Perl 5 programming language system itself.
109+
110+
=cut
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Implementation of a pure-perl on_scope_end for perls > 5.10
2+
# (relies on Hash::Util:FieldHash)
3+
4+
package # hide from pause
5+
B::Hooks::EndOfScope::PP::FieldHash;
6+
7+
use strict;
8+
use warnings;
9+
10+
our $VERSION = '0.28';
11+
12+
use Tie::Hash ();
13+
use Hash::Util::FieldHash 'fieldhash';
14+
15+
# Here we rely on a combination of several behaviors:
16+
#
17+
# * %^H is deallocated on scope exit, so any references to it disappear
18+
# * A lost weakref in a fieldhash causes the corresponding key to be deleted
19+
# * Deletion of a key on a tied hash triggers DELETE
20+
#
21+
# Therefore the DELETE of a tied fieldhash containing a %^H reference will
22+
# be the hook to fire all our callbacks.
23+
24+
fieldhash my %hh;
25+
{
26+
package # hide from pause too
27+
B::Hooks::EndOfScope::PP::_TieHintHashFieldHash;
28+
our @ISA = ( 'Tie::StdHash' ); # in Tie::Hash, in core
29+
sub DELETE {
30+
my $ret = shift->SUPER::DELETE(@_);
31+
B::Hooks::EndOfScope::PP::__invoke_callback($_) for @$ret;
32+
$ret;
33+
}
34+
}
35+
36+
sub on_scope_end (&) {
37+
$^H |= 0x020000;
38+
39+
tie(%hh, 'B::Hooks::EndOfScope::PP::_TieHintHashFieldHash')
40+
unless tied %hh;
41+
42+
push @{ $hh{\%^H} ||= [] }, $_[0];
43+
}
44+
45+
1;

0 commit comments

Comments
 (0)