| 1 | #################################################################### | ||||||||||
| 2 | # | ||||||||||
| 3 | # This file was generated using XDR::Parse version v1.0.1, | ||||||||||
| 4 | # XDR::Gen version 1.1.2 and LibVirt version v12.9.0 | ||||||||||
| 5 | # | ||||||||||
| 6 | # Don't edit this file, use the source template instead | ||||||||||
| 7 | # | ||||||||||
| 8 | # ANY CHANGES HERE WILL BE LOST ! | ||||||||||
| 9 | # | ||||||||||
| 10 | #################################################################### | ||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use v5.14; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | package Protocol::Sys::Virt::KeepAlive v12.9.0; | ||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | ▶ | use Log::Any qw($log); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | use Protocol::Sys::Virt::KeepAlive::XDR; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | ▶ | use Protocol::Sys::Virt::Transport::XDR; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | my $msgs = 'Protocol::Sys::Virt::KeepAlive::XDR'; | |||||||||
| 23 | 1 | my $type = 'Protocol::Sys::Virt::Transport::XDR'; | |||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 26 | 0 | my ($class, %args) = @_; | |||||||||
| 27 | return bless { | ||||||||||
| 28 | inactive => 0, | ||||||||||
| 29 | max_inactive => 10, | ||||||||||
| 30 | 0 | ▶ | on_ack => sub { }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||
| 31 | 0 | ▶ | on_fail => sub { }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||
| 32 | 0 | ▶ | on_ping => sub { }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||
| 33 | 0 | ▶ | sender => sub { croak 'Not registered with a transport'; }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 34 | 0 | %args | |||||||||
| 35 | }, $class; | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub _unexpected_msg { | ||||||||
|
Subroutine
_unexpected_msg: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | 0 | croak 'Unexpected message'; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub register { | ||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 43 | 0 | my ($self, $transport) = @_; | |||||||||
| 44 | |||||||||||
| 45 | $self->{sender} = $transport->register( | ||||||||||
| 46 | $msgs->PROGRAM, | ||||||||||
| 47 | $msgs->PROTOCOL_VERSION, | ||||||||||
| 48 | { | ||||||||||
| 49 | on_reply => \&_unexpected_msg, | ||||||||||
| 50 | on_call => \&_unexpected_msg, | ||||||||||
| 51 | 0 | ▶ | on_message => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 52 | 0 | my %args = @_; | |||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | if ($args{header}->{proc} == $msgs->PROC_PONG) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 0 | $self->{inactive} = 0; # our PING; keep pinging | |||||||||
| 56 | 0 | return $self->{on_ack}->($self, $transport); | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 0 | $self->mark_active; | |||||||||
| 60 | 0 | ▶ | if ($args{header}->{proc} == $msgs->PROC_PING) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | return $self->{on_ping}->($self, $transport); | |||||||||
| 62 | } | ||||||||||
| 63 | 0 | return; | |||||||||
| 64 | }, | ||||||||||
| 65 | 0 | on_stream => \&_unexpected_msg | |||||||||
| 66 | }); | ||||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub mark_active { | ||||||||
|
Subroutine
mark_active: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 71 | 0 | $_[0]->{inactive} = -1; # external activity | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | sub ping { | ||||||||
|
Subroutine
ping: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 75 | 0 | my ($self) = @_; | |||||||||
| 76 | |||||||||||
| 77 | 0 | $self->{inactive}++; | |||||||||
| 78 | 0 | ▶ | if ($self->{inactive} > $self->{max_inactive}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 0 | return $self->{on_fail}->($self); | |||||||||
| 80 | } | ||||||||||
| 81 | 0 | ▶ | if ($self->{inactive}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | 0 | $log->trace("Inactivity timer: $self->{inactive}"); | |||||||||
| 83 | 0 | return $self->{sender}->($msgs->PROC_PING, $type->MESSAGE, data => ''); | |||||||||
| 84 | } | ||||||||||
| 85 | else { | ||||||||||
| 86 | 0 | $log->trace("Activity found; no need to PING"); | |||||||||
| 87 | 0 | return; | |||||||||
| 88 | } | ||||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | 0 | ▶ | sub pong { | ||||||||
|
Subroutine
pong: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 92 | 0 | my ($self) = @_; | |||||||||
| 93 | 0 | $self->{sender}->($msgs->PROC_PONG, $type->MESSAGE, data => ''); | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 1 | 1; | |||||||||
| 97 | |||||||||||
| 98 | __END__ | ||||||||||