DJabberd/Delivery/S2S.pm

filter: Statementstmt 56.7% 21 / 37 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 0.0% 0 / 4 totaltotal 41.5% 27 / 65 CC 7 SCAR 29.0
CC
7
Cov
42%
deliver
42.0
get_queue_for_domain
6.0
run_after
2.0
CRAP 18.1
« DJabberd/Presence.pm ↑ Summary DJabberd/Delivery/ComponentConnection.pm »
1 package DJabberd::Delivery::S2S;
2 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use base 'DJabberd::Delivery';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 20 ▶use DJabberd::Queue::ServerOut;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 ▶use DJabberd::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 20 our $logger = DJabberd::Log->get_logger;
9  
10 0 ▶sub run_after { ("DJabberd::Delivery::Local") }
Subroutine run_after: not called CC=1 SCAR=6.9
Pod undocumented
11  
12 42 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
13 42 my $class = shift;
14 42 my $self = $class->SUPER::new(@_);
15 42 $self->{cache} = {}; # domain -> DJabberd::Queue::ServerOut
16 42 return $self;
17 }
18  
19 0 ▶sub deliver {
Subroutine deliver: not called CC=6 SCAR=37.4
Pod undocumented
20 0 my ($self, $vhost, $cb, $stanza) = @_;
21 0 ▶ die unless $vhost == $self->{vhost}; # sanity check
Branch: 1 branch
BranchTrueFalseTotal
unless $vhost == $self->{"vhost"} 0 0 0
22  
23 # don't do s2s if the vhost doesn't have it enabled
24 0 ▶ unless ($vhost->s2s) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($vhost->s2s) 0 0 0
25 0 $cb->declined;
26 0 return;
27 }
28  
29 0 ▶ my $to = $stanza->to_jid
Branch: 1 branch
BranchTrueFalseTotal
my $to = $stanza->to_jid or return $cb->declined 0 0 0
30 or return $cb->declined;
31  
32 # don't initiate outgoing connections back to ourself
33 0 my $domain = $to->domain;
34 0 ▶ if ($vhost->handles_domain($domain)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vhost->handles_domain($domain)) 0 0 0
35 0 return $cb->declined;
36 }
37  
38 0 $logger->debug("s2s delivery attempt for $to");
39  
40 # FIXME: let get_conn_for_domain return an error code or something
41 # which we can then pass along smarter to the callback, so client gets
42 # a good error?
43 0 ▶ my $out_queue = $self->get_queue_for_domain($domain) or
Branch: 1 branch
BranchTrueFalseTotal
my $out_queue = $self->get_queue_for_domain($domain) or return $cb->declined 0 0 0
44 return $cb->declined;
45  
46 0 $DJabberd::Stats::counter{deliver_s2s}++;
47 0 $out_queue->queue_stanza($stanza, $cb);
48 }
49  
50 0 ▶sub get_queue_for_domain {
Subroutine get_queue_for_domain: not called CC=2 SCAR=17.9
Pod undocumented
51 0 my ($self, $domain) = @_;
52 # TODO: we need to clean this periodically, like when connections timeout or fail
53 return $self->{cache}{$domain} ||=
54 DJabberd::Queue::ServerOut->new(source => $self,
55 domain => $domain,
56 0 ▶ vhost => $self->{vhost});
Condition0%0/3
$self->{"cache"}{$domain} ||= "DJabberd::Queue::ServerOut"->new("source", $self, "domain", $domain, "vhost", $self->{"vhost"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"cache"}{$domain} ||= "DJabberd::Queue::ServerOut"->new("source", $self, "domain", $domain, "vhost", $self->{"vhost"})
$self->{"cache"}{$domain} "DJabberd::Queue::ServerOut"->new("source", $self, "domain", $domain, "vhost", $self->{"vhost"})
Truth table0%0/3
A ||= B
A= $self->{"cache"}{$domain}B= "DJabberd::Queue::ServerOut"->new("source", $self, "domain", $domain, "vhost", $self->{"vhost"})
ABresult
1X1
011
000
57 }
58  
59 20 1;
« DJabberd/Presence.pm ↑ Summary DJabberd/Delivery/ComponentConnection.pm »