Make post loop callbacks a local var so we don't have to iterate through as
much git-svn-id: https://svn.perl.org/qpsmtpd/branches/high_perf@419 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
37c96a1773
commit
e3a5d6c3c6
@ -73,7 +73,7 @@ our (
|
|||||||
%OtherFds, # A hash of "other" (non-Danga::Socket) file
|
%OtherFds, # A hash of "other" (non-Danga::Socket) file
|
||||||
# descriptors for the event loop to track.
|
# descriptors for the event loop to track.
|
||||||
$PostLoopCallback, # subref to call at the end of each loop, if defined
|
$PostLoopCallback, # subref to call at the end of each loop, if defined
|
||||||
$LocalPostLoopCallback, # true if there is a local post loop callback in effect
|
%PLCMap, # fd (num) -> PostLoopCallback
|
||||||
);
|
);
|
||||||
|
|
||||||
%OtherFds = ();
|
%OtherFds = ();
|
||||||
@ -375,13 +375,8 @@ sub PostEventLoop {
|
|||||||
@ToClose = ();
|
@ToClose = ();
|
||||||
|
|
||||||
# now we're at the very end, call per-connection callbacks if defined
|
# now we're at the very end, call per-connection callbacks if defined
|
||||||
if ($LocalPostLoopCallback) {
|
for my $plc (values %PLCMap) {
|
||||||
for my $fd (%DescriptorMap) {
|
return unless $plc->(\%DescriptorMap, \%OtherFds);
|
||||||
my $pob = $DescriptorMap{$fd};
|
|
||||||
if( defined $pob->{post_loop_callback} ) {
|
|
||||||
return unless $pob->{post_loop_callback}->(\%DescriptorMap, \%OtherFds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# now we're at the very end, call global callback if defined
|
# now we're at the very end, call global callback if defined
|
||||||
@ -810,12 +805,10 @@ sub SetPostLoopCallback {
|
|||||||
if(ref $class) {
|
if(ref $class) {
|
||||||
my Danga::Socket $self = $class;
|
my Danga::Socket $self = $class;
|
||||||
if( defined $ref && ref $ref eq 'CODE' ) {
|
if( defined $ref && ref $ref eq 'CODE' ) {
|
||||||
$LocalPostLoopCallback++;
|
$PLCMap{$self->{fd}} = $ref;
|
||||||
$self->{post_loop_callback} = $ref;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$LocalPostLoopCallback--;
|
delete $PLCMap{$self->{fd}};
|
||||||
delete $self->{post_loop_callback};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -823,6 +816,11 @@ sub SetPostLoopCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub DESTROY {
|
||||||
|
my Danga::Socket $self = shift;
|
||||||
|
delete $PLCMap{$self->{fd}};
|
||||||
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
### U T I L I T Y F U N C T I O N S
|
### U T I L I T Y F U N C T I O N S
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user