| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Module Generic - ~/lib/Module/Generic/SharedMemXS.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.4.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2026 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 1970/01/01 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2026/09/25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | package Module::Generic::SharedMemXS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use v5.16.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | warnings::register_categories( 'Module::Generic' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use vars qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | $SUPPORTED_RE $SYSV_SUPPORTED $SEMOP_ARGS $N $HAS_B64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # This is disruptive for everybody. Bad idea. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # use JSON 4.03 qw( -convert_blessed_universally ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use JSON 4.03; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use Module::Generic::Global ':const'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | ▶ | use Storable::Improved (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | SHM_BUFSIZ => 65536, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | SEM_LOCKER => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | SEM_MARKER => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | SHM_LOCK_WAIT => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | SHM_LOCK_EX => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | SHM_LOCK_UN => -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | SHM_EXISTS => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | LOCK_SH => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | LOCK_EX => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | LOCK_NB => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | LOCK_UN => 8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | $SUPPORTED_RE = qr/IPC\/SysV/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | ▶ | if( $Config{extensions} =~ /$SUPPORTED_RE/ && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$Module::Generic::SharedMemXS::Config{"extensions"} =~ /$Module::Generic::SharedMemXS::SUPPORTED_RE/u and not $^O =~ /^(?:Android|dos|MSWin32|os2|VMS|riscos)/iu and $Module::Generic::SharedMemXS::Config{"d_sem"} eq "define" and $Module::Generic::SharedMemXS::Config{"d_msg"} eq "define"
$Module::Generic::SharedMemXS::Config{"extensions"} =~ /$Module::Generic::SharedMemXS::SUPPORTED_RE/u and not $^O =~ /^(?:Android|dos|MSWin32|os2|VMS|riscos)/iu and $Module::Generic::SharedMemXS::Config{"d_sem"} eq "define"
$Module::Generic::SharedMemXS::Config{"extensions"} =~ /$Module::Generic::SharedMemXS::SUPPORTED_RE/u and not $^O =~ /^(?:Android|dos|MSWin32|os2|VMS|riscos)/iu
MC/DC0%0/4
$Module::Generic::SharedMemXS::Config{"extensions"} =~ /$Module::Generic::SharedMemXS::SUPPORTED_RE/u and not $^O =~ /^(?:Android|dos|MSWin32|os2|VMS|riscos)/iu and $Module::Generic::SharedMemXS::Config{"d_sem"} eq "define" and $Module::Generic::SharedMemXS::Config{"d_msg"} eq "define"
$Module::Generic::SharedMemXS::Config{"extensions"} =~ /$Module::Generic::SharedMemXS::SUPPORTED_RE/u
not $^O =~ /^(?:Android|dos|MSWin32|os2|VMS|riscos)/iu
$Module::Generic::SharedMemXS::Config{"d_sem"} eq "define"
$Module::Generic::SharedMemXS::Config{"d_msg"} eq "define"
Truth table20%1/5
A and not(B) and C and D
A= $Module::Generic::SharedMemXS::Config{"extensions"} =~ /$Module::Generic::SharedMemXS::SUPPORTED_RE/uB= not $^O =~ /^(?:Android|dos|MSWin32|os2|VMS|riscos)/iuC= $Module::Generic::SharedMemXS::Config{"d_sem"} eq "define"D= $Module::Generic::SharedMemXS::Config{"d_msg"} eq "define"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | $^O !~ /^(?:Android|dos|MSWin32|os2|VMS|riscos)/i && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # we need semaphore and messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $Config{d_sem} eq 'define' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | $Config{d_msg} eq 'define' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | require IPC::SysV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | IPC::SysV->import( qw( IPC_RMID IPC_PRIVATE IPC_SET IPC_STAT IPC_CREAT IPC_EXCL IPC_NOWAIT | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | SEM_UNDO S_IRWXU S_IRWXG S_IRWXO S_IRUSR S_IWUSR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | GETNCNT GETZCNT GETVAL SETVAL GETPID GETALL SETALL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | shmat shmdt memread memwrite ftok ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | require IPC::SharedMem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | require IPC::Semaphore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | $SYSV_SUPPORTED = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | no strict 'subs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | eval( <<'EOT' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | our $SEMOP_ARGS = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | (LOCK_EX) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1, 0, 0, # wait for readers to finish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2, 0, 0, # wait for writers to finish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2, 1, SEM_UNDO, # assert write lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | (LOCK_EX | LOCK_NB) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1, 0, IPC_NOWAIT, # wait for readers to finish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2, 0, IPC_NOWAIT, # wait for writers to finish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2, 1, (SEM_UNDO | IPC_NOWAIT), # assert write lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | (LOCK_EX | LOCK_UN) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2, -1, (SEM_UNDO | IPC_NOWAIT), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | (LOCK_SH) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2, 0, 0, # wait for writers to finish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1, 1, SEM_UNDO, # assert shared read lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | (LOCK_SH | LOCK_NB) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2, 0, IPC_NOWAIT, # wait for writers to finish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1, 1, (SEM_UNDO | IPC_NOWAIT), # assert shared read lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | (LOCK_SH | LOCK_UN) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1, -1, (SEM_UNDO | IPC_NOWAIT), # remove shared read lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | EOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | warn( "Error while trying to eval \$SEMOP_ARGS: $@\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $SYSV_SUPPORTED = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # Credits IPC::SysV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | ▶ | $N = do { my $foo = eval { pack "L!", 0 }; $@ ? '' : '!' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | our @EXPORT_OK = qw(LOCK_EX LOCK_SH LOCK_NB LOCK_UN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 4 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | all => [qw( LOCK_EX LOCK_SH LOCK_NB LOCK_UN )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | lock => [qw( LOCK_EX LOCK_SH LOCK_NB LOCK_UN )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 'flock' => [qw( LOCK_EX LOCK_SH LOCK_NB LOCK_UN )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 4 | our $VERSION = 'v0.4.1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 6 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 6 | $self->{base64} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # Default action when accessing a shared memory? If 1, it will create it if it does not exist already | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 6 | $self->{create} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # If true, this will destroy both the shared memory and the semaphore upon end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | $self->{destroy} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # If true, this will destroy only the semaphore upon end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | $self->{destroy_semaphore} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | $self->{exclusive} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | ▶ | no strict 'subs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 6 | ▶ | $self->{key} = &IPC::SysV::IPC_PRIVATE if( $SYSV_SUPPORTED ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 6 | $self->{mode} = 0666; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 6 | $self->{serial} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # SHM_BUFSIZ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 6 | $self->{size} = SHM_BUFSIZ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 6 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # $self->{_packing_method} = 'storable'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Storable keps breaking :( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # I leave the feature of using it as a choice to the user, but defaults to JSON | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 6 | $self->{_packing_method} = 'json'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 6 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 6 | ▶ | $self->{destroy_semaphore} = 1 if( $self->{destroy} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 6 | $self->{owner} = $$; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 6 | $self->{locked} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 6 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | sub addr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addr: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | my $shm = $self->_ipc_shared || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
$self->_ipc_shared
Truth table50%1/2
A
A= $self->_ipc_shared
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | return( $self->error( "No IPC::SharedMem object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | my @rv = eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | return( $shm->addr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return( $self->error( "Error with \$shm->addr: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | return( $rv[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # This class does not convert to an HASH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub as_hash { return( $_[0] ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | sub attach | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attach: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $flags = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $flags = $self->flags if( !defined( $flags ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | my $shm = $self->_ipc_shared || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
$self->_ipc_shared
Truth table0%0/2
A
A= $self->_ipc_shared
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | return( $self->error( "No IPC::SharedMem object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | my @rv = eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return( $shm->attach( $flags ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return( $self->error( "Error with \$shm->attach: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | return( $rv[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | ▶ | sub base64 { return( shift->_set_get_scalar( 'base64', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base64: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub cbor { return( shift->_packing_method( 'cbor' ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cbor: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub close { return( shift->remove( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 8 | ▶ | sub create { return( shift->_set_get_boolean( 'create', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub delete { return( shift->remove( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | sub destroy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
destroy: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 11 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 11 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 6 | my $val = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | $self->_set_get_boolean( 'destroy', $val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 6 | ▶ | $self->_set_get_boolean( 'destroy_semaphore', 1 ) if( $val ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 11 | return( $self->_set_get_boolean( 'destroy' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 8 | ▶ | sub destroy_semaphore { return( shift->_set_get_boolean( 'destroy_semaphore', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
destroy_semaphore: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | sub detach | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detach: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | my $shm = $self->_ipc_shared || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
$self->_ipc_shared
Truth table50%1/2
A
A= $self->_ipc_shared
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | return( $self->error( "No IPC::SharedMem object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | $rv = $shm->detach; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return( $self->error( "Error detaching shared memory block previously attached: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | return( $self->error( "Unable to detach from shared memory: $!" ) ) if( !defined( $rv ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | sub exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists: called CC=10 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 5 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 5 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 5 | ▶ | if( ref( $_[0] ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $opts = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 5 | @$opts{ qw( key mode size ) } = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 5 | ▶ | $opts->{size} = $self->size unless( length( $opts->{size} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 5 | $opts->{size} = int( $opts->{size} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | ▶ | $opts->{key} //= $self->key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"key"} //= $self->key
MC/DC0%0/2
$opts->{"key"} //= $self->key
$opts->{"key"}
$self->key
Truth table33%1/3
A //= B
A= $opts->{"key"}B= $self->key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 5 | my $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 5 | ▶ | if( length( $opts->{key} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 5 | ▶ | my $key_val = $self->_verify_key( $opts->{key} ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_verify_key($opts->{'key'}) || (return $self->pass_error)
MC/DC0%0/1
$self->_verify_key($opts->{'key'}) || (return $self->pass_error)
$self->_verify_key($opts->{'key'})
Truth table50%1/2
A
A= $self->_verify_key($opts->{'key'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | $key = $self->_str2key( $key_val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 5 | my $flags = $self->flags({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | create => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | exclusive => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | mode => 0644, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | ▶ | no strict 'subs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | my $shm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 5 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 5 | ▶ | if( defined( $key ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 5 | $shm = IPC::SharedMem->new( $key, $opts->{size}, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 5 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if( $@ =~ /shmget[[:blank:]\h]+not[[:blank:]\h]+implemented/i ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return( $self->error( "IPC SysV is supported, but somehow shmget is not implemented: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | return( $self->error( "Error trying to find out if this shared memory segment already exists: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # $shm = IPC::SharedMem->new( &IPC::SysV::IPC_PRIVATE, $opts->{size}, $flags ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # No key is specified, thus we would be using IPC_PRIVATE, which would mean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # creating a new shared memory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 5 | ▶ | return(0) if( !defined( $shm ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | sub flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flags: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 8 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 8 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 4 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 4 | ▶ | no strict 'subs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 8 | ▶ | $opts->{create} = $self->create unless( length( $opts->{create} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 8 | ▶ | $opts->{exclusive} = $self->exclusive unless( length( $opts->{exclusive} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 8 | ▶ | $opts->{mode} = $self->mode unless( length( $opts->{mode} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 8 | my $flags = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 8 | ▶ | $flags |= &IPC::SysV::IPC_CREAT if( $opts->{create} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 8 | ▶ | $flags |= &IPC::SysV::IPC_EXCL if( $opts->{exclusive} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 8 | ▶ | my $mode = length( $opts->{mode} ) ? $opts->{mode} : 0666; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 8 | $flags |= $mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 8 | return( $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | sub id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 9 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 9 | ▶ | my $shm = $self->_ipc_shared || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
$self->_ipc_shared
Truth table50%1/2
A
A= $self->_ipc_shared
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | return( $self->error( "No IPC::SharedMem object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 9 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 9 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 9 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 9 | $rv = $shm->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 9 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | return( $self->error( "Error with \$shm->id: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 9 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | sub json { return( shift->_packing_method( 'json' ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
json: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 14 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 14 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 14 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | ▶ | my $key = $self->_verify_key( shift( @_ ) ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_verify_key(shift @_) || (return $self->pass_error)
MC/DC0%0/1
$self->_verify_key(shift @_) || (return $self->pass_error)
$self->_verify_key(shift @_)
Truth table50%1/2
A
A= $self->_verify_key(shift @_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 6 | $self->{key} = $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 6 | $self->{serial} = $self->_str2key( $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 14 | return( $self->{key} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | sub lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lock: called CC=11 SCAR=25.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 5 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 5 | my $type = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 5 | my $timeout = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # $type = LOCK_EX if( !defined( $type ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 5 | ▶ | $type = LOCK_SH if( !defined( $type ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 5 | ▶ | return( $self->unlock ) if( ( $type & LOCK_UN ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 5 | ▶ | return(1) if( $self->locked & $type ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 5 | ▶ | $timeout = 0 if( !defined( $timeout ) || $timeout !~ /^\d+$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $timeout and $timeout =~ /^\d+$/
MC/DC0%0/2
defined $timeout and $timeout =~ /^\d+$/
defined $timeout
$timeout =~ /^\d+$/
Truth table33%1/3
A and B
A= defined $timeoutB= $timeout =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # If the lock is different, release it first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 5 | ▶ | $self->unlock if( $self->locked ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 5 | ▶ | my $sem = $self->_sem || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
$self->_sem
Truth table50%1/2
A
A= $self->_sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | return( $self->error( "No IPC::Semaphore object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 5 | my $semid = $sem->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 5 | ▶ | return( $self->error( "No semaphore id set yet." ) ) if( !defined( $semid ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 5 | my $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 5 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 5 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | local $SIG{ALRM} = sub{ die( "timeout" ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 5 | alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 5 | $rc = $sem->op( @{$SEMOP_ARGS->{ $type }} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 5 | alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 5 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return( $self->error( "Unable to set a lock: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 5 | ▶ | if( $rc ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 5 | $self->locked( $type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # # $self->message( 3, "Unable to set a lock on semaphore id \"$semid\": $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # return( $self->error( "Failed to set a lock on semaphore id \"$semid\" for lock type $type: $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 5 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 35 | ▶ | sub locked { return( shift->_set_get_scalar( 'locked', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locked: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 12 | ▶ | sub mode { return( shift->_set_get_scalar( 'mode', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | sub open | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open: called CC=33 SCAR=43.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 3 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 3 | ▶ | if( ref( $_[0] ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 2 | $opts = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | @$opts{ qw( key mode size ) } = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 3 | ▶ | $opts->{size} = $self->size unless( length( $opts->{size} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | $opts->{size} = int( $opts->{size} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | ▶ | $opts->{mode} //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts->{"mode"} //= ""
MC/DC100%1/1
$opts->{"mode"} //= ""
$opts->{"mode"}
Truth table100%2/2
A
A= $opts->{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 3 | ▶ | $opts->{key} //= $self->key // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$opts->{"key"} //= $self->key // ""
$self->key // ""
MC/DC0%0/1
$opts->{"key"} //= $self->key // ""
$opts->{"key"}
Truth table50%1/2
A
A= $opts->{"key"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | my $create = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 3 | ▶ | if( $opts->{mode} eq 'w' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | $create++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | elsif( $opts->{mode} eq 'r' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $create = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | ▶ | elsif( !ref( $opts->{key} ) && $opts->{key} =~ s/^>// ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
not ref $opts->{"key"} and $opts->{"key"} =~ s/^>//
MC/DC0%0/2
not ref $opts->{"key"} and $opts->{"key"} =~ s/^>//
not ref $opts->{"key"}
$opts->{"key"} =~ s/^>//
Truth table33%1/3
not(A) and B
A= not ref $opts->{"key"}B= $opts->{"key"} =~ s/^>//
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $create++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ▶ | elsif( !ref( $opts->{key} ) && $opts->{key} =~ s/^<// ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
not ref $opts->{"key"} and $opts->{"key"} =~ s/^<//
MC/DC0%0/2
not ref $opts->{"key"} and $opts->{"key"} =~ s/^<//
not ref $opts->{"key"}
$opts->{"key"} =~ s/^<//
Truth table33%1/3
not(A) and B
A= not ref $opts->{"key"}B= $opts->{"key"} =~ s/^<//
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $create = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | $create = $self->create; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 3 | my $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 3 | ▶ | if( length( $opts->{key} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 3 | ▶ | my $key_val = $self->_verify_key( $opts->{key} ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_verify_key($opts->{'key'}) || (return $self->pass_error)
MC/DC0%0/1
$self->_verify_key($opts->{'key'}) || (return $self->pass_error)
$self->_verify_key($opts->{'key'})
Truth table50%1/2
A
A= $self->_verify_key($opts->{'key'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 3 | ▶ | $key = $self->_str2key( $key_val ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->_str2key($key_val) || (return $self->error(q[Cannot get serial from key '], $self->_is_array($key_val) ? join(q[', '], @$key_val) : $key_val, q[': ], $self->error))
MC/DC0%0/1
$self->_str2key($key_val) || (return $self->error(q[Cannot get serial from key '], $self->_is_array($key_val) ? join(q[', '], @$key_val) : $key_val, q[': ], $self->error))
$self->_str2key($key_val)
Truth table50%1/2
A
A= $self->_str2key($key_val)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | return( $self->error( "Cannot get serial from key '", ( $self->_is_array( $key_val ) ? join( "', '", @$key_val ) : $key_val ), "': ", $self->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | my $flags = $self->flags( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | create => $create, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 3 | ▶ | ( $opts->{mode} =~ /^\d+$/ ? ( mode => $opts->{mode} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 3 | my $shm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 3 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 3 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 3 | ▶ | $key //= &IPC::SysV::IPC_PRIVATE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$key //= &IPC::SysV::IPC_PRIVATE
MC/DC0%0/2
$key //= &IPC::SysV::IPC_PRIVATE
$key
&IPC::SysV::IPC_PRIVATE
Truth table33%1/3
A //= B
A= $keyB= &IPC::SysV::IPC_PRIVATE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 3 | $shm = IPC::SharedMem->new( $key, $opts->{size}, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 3 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | return( $self->error( "Error instantiating a new IPC::SharedMem object: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 3 | ▶ | if( !defined( $shm ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | return( $self->error( "Unable to create shared memory block with key '", ( $self->_is_array( $opts->{key} ) ? join( "', '", @{$opts->{key}} ) : $opts->{key} ), "' (", ( $key // '' ), ") and flags \"$flags\": $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$key // ""
MC/DC0%0/1
$key // ""
$key
Truth table0%0/2
A
A= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 3 | my $sem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 3 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 3 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 3 | $sem = IPC::Semaphore->new( $key, 3, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 3 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | return( $self->error( "Error instantiating a new IPC::Semaphore object: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 3 | ▶ | if( !defined( $sem ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | return( $self->error( "Unable to create semaphore with key '", ( $self->_is_array( $opts->{key} ) ? join( "', '", @{$opts->{key}} ) : $opts->{key} ), "' (", ( $key // '' ), ") and flags \"$flags\": $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$key // ""
MC/DC0%0/1
$key // ""
$key
Truth table0%0/2
A
A= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | my $new = $self->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | key => $opts->{key}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | debug => $self->debug, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | mode => $self->mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | destroy => $self->destroy, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | destroy_semaphore => $self->destroy_semaphore, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | exclusive => $self->exclusive, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | _packing_method => $self->_packing_method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | ) || return( $self->error( "Cannot create object with key '", ( $self->_is_array( $opts->{key} ) ? join( "', '", @{$opts->{key}} ) : $opts->{key} ), "': ", $self->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->new('key', $opts->{'key'}, 'debug', $self->debug, 'mode', $self->mode, 'destroy', $self->destroy, 'destroy_semaphore', $self->destroy_semaphore, 'exclusive', $self->exclusive, '_packing_method', $self->_packing_method) || (return $self->error(q[Cannot create object with key '], $self->_is_array($opts->{'key'}) ? join(q[', '], @{$opts->{'key'};}) : $opts->{'key'}, q[': ], $self->error))
MC/DC0%0/1
$self->new('key', $opts->{'key'}, 'debug', $self->debug, 'mode', $self->mode, 'destroy', $self->destroy, 'destroy_semaphore', $self->destroy_semaphore, 'exclusive', $self->exclusive, '_packing_method', $self->_packing_method) || (return $self->error(q[Cannot create object with key '], $self->_is_array($opts->{'key'}) ? join(q[', '], @{$opts->{'key'};}) : $opts->{'key'}, q[': ], $self->error))
$self->new('key', $opts->{'key'}, 'debug', $self->debug, 'mode', $self->mode, 'destroy', $self->destroy, 'destroy_semaphore', $self->destroy_semaphore, 'exclusive', $self->exclusive, '_packing_method', $self->_packing_method)
Truth table50%1/2
A
A= $self->new('key', $opts->{'key'}, 'debug', $self->debug, 'mode', $self->mode, 'destroy', $self->destroy, 'destroy_semaphore', $self->destroy_semaphore, 'exclusive', $self->exclusive, '_packing_method', $self->_packing_method)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 3 | $new->{base64} = $self->base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 3 | $new->{size} = $opts->{size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 3 | $new->{flags} = $flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | $new->{create} = $create; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | $new->{_ipc_shared} = $shm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 3 | $new->{_sem} = $sem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 3 | my $id = $new->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # Array to maintain the order in which shared memory object were created, so they can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # be removed in that order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 3 | my $shem_repo = Module::Generic::Global->new( 'shem_repo' => CORE::ref( $self ), key => CORE::ref( $self ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 3 | my $id2obj_repo = Module::Generic::Global->new( 'id2obj' => CORE::ref( $self ), key => $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 3 | $shem_repo->lock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 3 | ▶ | my $all_shem = $shem_repo->get // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$shem_repo->get // []
MC/DC100%1/1
$shem_repo->get // []
$shem_repo->get
Truth table100%2/2
A
A= $shem_repo->get
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | CORE::push( @$all_shem, $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 3 | $shem_repo->set( $all_shem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 3 | $shem_repo->unlock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 3 | $id2obj_repo->lock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 3 | $id2obj_repo->set( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 3 | $id2obj_repo->unlock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 3 | ▶ | if( !defined( $sem->op( @{$SEMOP_ARGS->{(LOCK_SH)}} ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | return( $self->error( "Unable to set lock on sempahore: $!" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 3 | my $there = $new->stat( SEM_MARKER ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 3 | ▶ | if( defined( $there ) && $there == SHM_EXISTS ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $there and $there == 1
MC/DC50%1/2
defined $there and $there == 1
defined $there
$there == 1
Truth table66%2/3
A and B
A= defined $thereB= $there == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # Binding to existing segment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # We initialise the semaphore with value of 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 2 | ▶ | $new->stat( SEM_MARKER, SHM_EXISTS ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | return( $new->error( "Unable to set semaphore during object creation: ", $new->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | $sem->op( @{$SEMOP_ARGS->{(LOCK_SH | LOCK_UN)}} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 3 | return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | sub op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op: called CC=6 SCAR=18.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 5 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 5 | ▶ | return( $self->error( "No argument was provided!" ) ) if( !scalar( @_ ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 5 | ▶ | return( $self->error( "Invalid number of argument: '", join( ', ', @_ ), "'." ) ) if( @_ % 3 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 5 | ▶ | my $sem = $self->_sem || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
$self->_sem
Truth table50%1/2
A
A= $self->_sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | return( $self->error( "No IPC::Semaphore object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 5 | my $id = $sem->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 5 | ▶ | return( $self->error( "No semaphore set yet. You must open the shared memory first to set the semaphore." ) ) if( !defined( $id ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 5 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 5 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 5 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 5 | $rv = $sem->op( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 5 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | return( $self->error( "Error passing operation list to semaphore id $id: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 5 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 2 | ▶ | sub owner { return( shift->_set_get_scalar( 'owner', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
owner: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | sub pid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pid: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $sem = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | return( $self->error( "No semaphore provided." ) ) if( !defined( $sem ) || !length( $sem ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $sem and length $sem
MC/DC0%0/2
defined $sem and length $sem
defined $sem
length $sem
Truth table0%0/3
A and B
A= defined $semB= length $sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | my $obj = $self->_sem || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
$self->_sem
Truth table0%0/2
A
A= $self->_sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | return( $self->error( "No IPC::Semaphore object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $rv = $obj->getpid( $sem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | return( $self->error( "Error getting the last process id of the semaphore: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | return( ( defined( $rv ) && $rv ) ? 0 + $rv : undef() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $rv and $rv
MC/DC0%0/2
defined $rv and $rv
defined $rv
$rv
Truth table0%0/3
A and B
A= defined $rvB= $rv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | sub rand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rand: not called CC=3 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | my $size = $self->size || 1024; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->size || 1024
MC/DC0%0/1
$self->size || 1024
$self->size
Truth table0%0/2
A
A= $self->size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 4 | ▶ | no strict 'subs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | my $key = shmget( &IPC::SysV::IPC_PRIVATE, $size, &IPC::SysV::S_IRWXU | &IPC::SysV::S_IRWXG | &IPC::SysV::S_IRWXO ) || return( $self->error( "Unable to generate a share memory key: $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shmget(&IPC::SysV::IPC_PRIVATE, $size, &IPC::SysV::S_IRWXU | &IPC::SysV::S_IRWXG | &IPC::SysV::S_IRWXO) || (return $self->error("Unable to generate a share memory key: $!"))
MC/DC0%0/1
shmget(&IPC::SysV::IPC_PRIVATE, $size, &IPC::SysV::S_IRWXU | &IPC::SysV::S_IRWXG | &IPC::SysV::S_IRWXO) || (return $self->error("Unable to generate a share memory key: $!"))
shmget(&IPC::SysV::IPC_PRIVATE, $size, &IPC::SysV::S_IRWXU | &IPC::SysV::S_IRWXG | &IPC::SysV::S_IRWXO)
Truth table0%0/2
A
A= shmget(&IPC::SysV::IPC_PRIVATE, $size, &IPC::SysV::S_IRWXU | &IPC::SysV::S_IRWXG | &IPC::SysV::S_IRWXO)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | return( $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # $self->read( $buffer, $size ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # $self->read( $buffer ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | # my $data = $self->read; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | sub read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: called CC=28 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 5 | my( $self, $buf ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 5 | ▶ | my $shm = $self->_ipc_shared || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
$self->_ipc_shared
Truth table50%1/2
A
A= $self->_ipc_shared
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | return( $self->error( "No IPC::SharedMem object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 5 | my $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 5 | ▶ | $size = int( $_[2] ) if( scalar( @_ ) > 2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # Optional length parameter for non-reference data only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 5 | ▶ | $size //= ( $self->size || SHM_BUFSIZ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$size //= $self->size || 65536
$self->size || 65536
MC/DC0%0/1
$size //= $self->size || 65536
$size
Truth table50%1/2
A
A= $size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 5 | $size = int( $size ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 5 | my $id = $shm->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 5 | ▶ | return( $self->error( "No shared memory id! Have you opened it first?" ) ) if( !defined( $id ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 5 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 5 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 5 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 5 | $buffer = $shm->read( 0, $size ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 5 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | return( $self->error( "Error with \$shm->read: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 5 | ▶ | if( !defined( $buffer ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | if( $! =~ /Invalid argument/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | return( $self->error( "Invalid argument used to read from shared memory. Size used was '$size' (", overload::StrVal( $size // 'undef' ), ")" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$size // "undef"
MC/DC0%0/1
$size // "undef"
$size
Truth table0%0/2
A
A= $size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return( $self->error( "Error reading from shared memory: $!" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 5 | my $packing = $self->_packing_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # NOTE: Get rid of nulls end padded only for CBOR::XS, but not for Sereal and Storable who know how to handle them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 5 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 5 | ▶ | if( CORE::length( $buffer ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # There may be encapsulation of data before writing data to memory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # e.g.: MG[14]something here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 5 | ▶ | if( index( $buffer, 'MG[' ) == 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 5 | my $def = substr( $buffer, 0, index( $buffer, ']' ) + 1, '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # Get the string length stored | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 5 | my $len = int( substr( $def, 3, -1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | # Remove any possible remaining unwanted data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 5 | substr( $buffer, $len, length( $buffer ), '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 5 | ▶ | if( $packing eq 'json' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 5 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 5 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 5 | $data = $self->_decode_json( $buffer ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 5 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | return( $self->error( "An error occured while decoding data using $packing with base64 set to '", ( $self->{base64} // '' ), "': $@" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | elsif( $packing eq 'cbor' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | $data = $self->deserialise( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | data => $buffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | serialiser => 'CBOR::XS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | allow_sharing => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | ( defined( $self->{base64} ) ? ( base64 => $self->{base64} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | return( $self->error( "An error occured while decoding data using $packing with base64 set to '", ( $self->{base64} // '' ), "': $@" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | elsif( $packing eq 'sereal' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | $data = $self->deserialise( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | data => $buffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | serialiser => 'Sereal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | freeze_callbacks => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | ( defined( $self->{base64} ) ? ( base64 => $self->{base64} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | return( $self->error( "An error occured while decoding data using $packing with base64 set to '", ( $self->{base64} // '' ), "': $@" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | # By default Storable::Improved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # $data = Storable::Improved::thaw( $buffer ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | $data = $self->deserialise( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | data => $buffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | serialiser => 'Storable::Improved', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | ( defined( $self->{base64} ) ? ( base64 => $self->{base64} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | return( $self->error( "An error occured while decoding data using $packing with base64 set to '", ( $self->{base64} // '' ), "': $@" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | $data = $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 5 | ▶ | if( scalar( @_ ) > 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 1 | $_[1] = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 1 | ▶ | return( CORE::length( $_[1] ) || "0E0" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
length $_[1] || '0E0'
MC/DC0%0/1
length $_[1] || '0E0'
length $_[1]
Truth table50%1/2
A
A= length $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 4 | return( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | sub remove | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=14 SCAR=28.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 1 | ▶ | return(1) if( $self->removed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 1 | my $shm = $self->{_ipc_shared}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 1 | ▶ | return(1) if( !defined( $shm ) || !length( $shm ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $shm and length $shm
MC/DC0%0/2
defined $shm and length $shm
defined $shm
length $shm
Truth table33%1/3
A and B
A= defined $shmB= length $shm
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1 | my $sem = $self->{_sem}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 1 | my( $id, $semid ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 1 | $id = $shm->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 1 | ▶ | $semid = $sem->id if( $sem ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 1 | $self->unlock(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 1 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 1 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 1 | ▶ | $sem->remove if( $sem ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 1 | $rv = $shm->remove; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 1 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | return( $self->error( "Error with \$shm->remove: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 1 | ▶ | if( $rv ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 1 | my $id2obj_repo = Module::Generic::Global->new( 'id2obj' => CORE::ref( $self ), key => $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 1 | $id2obj_repo->remove; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 1 | my $shem_repo = Module::Generic::Global->new( 'shem_repo' => CORE::ref( $self ), key => CORE::ref( $self ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 1 | $shem_repo->lock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 1 | ▶ | my $all_shem = $shem_repo->get // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$shem_repo->get // []
MC/DC0%0/1
$shem_repo->get // []
$shem_repo->get
Truth table50%1/2
A
A= $shem_repo->get
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 1 | my $modified = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 1 | ▶ | for( my $i = 0; $i < scalar( @$all_shem ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 1 | my $this_id = $all_shem->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 1 | ▶ | if( $this_id eq $id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 1 | CORE::splice( @$all_shem, $i, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 1 | $modified++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 1 | ▶ | if( $modified ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | $shem_repo->set( $all_shem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 1 | $self->{_ipc_shared} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | $self->{_sem} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | ▶ | return( ( defined( $rv ) && $rv ) ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $rv and $rv
MC/DC0%0/2
defined $rv and $rv
defined $rv
$rv
Truth table33%1/3
A and B
A= defined $rvB= $rv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | sub remove_semaphore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_semaphore: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | return(1) if( $self->removed_semaphore ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | my $sem = $self->_sem || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
$self->_sem
Truth table0%0/2
A
A= $self->_sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | return( $self->error( "No IPC::Semaphore object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | my $semid = $sem->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | $self->unlock(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | $rv = $sem->remove; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | return( $self->error( "Error removing semaphore object: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | if( !defined( $rv ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | warn( "Warning only: could not remove the semaphore id \"$semid\" with IPC::SysV::IPC_RMID value '", &IPC::SysV::IPC_RMID, "': $!" ) if( $self->_warnings_is_enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | $self->{_sem} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | return( $rv ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | sub removed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
removed: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 1 | my $shm = $self->{_ipc_shared}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 1 | ▶ | return(1) if( !defined( $shm ) || !length( $shm ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $shm and length $shm
MC/DC0%0/2
defined $shm and length $shm
defined $shm
length $shm
Truth table33%1/3
A and B
A= defined $shmB= length $shm
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 1 | return( $shm->is_removed ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | sub removed_semaphore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
removed_semaphore: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my $sem = $self->{_sem}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | ▶ | return( ( defined( $sem ) && $sem ) ? 0 : 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $sem and $sem
MC/DC0%0/2
defined $sem and $sem
defined $sem
$sem
Truth table0%0/3
A and B
A= defined $semB= $sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | sub reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | my $default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | $default = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | $default = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | $self->lock( LOCK_EX ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | $self->write( $default ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | $self->unlock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | sub semid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
semid: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 2 | ▶ | my $sem = $self->_sem || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
$self->_sem
Truth table50%1/2
A
A= $self->_sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | return( $self->error( "No IPC::Semaphore object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 2 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 2 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 2 | $rv = $sem->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 2 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | return( $self->error( "Error with retrieving semaphore id: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 2 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | sub sereal { return( shift->_packing_method( 'sereal' ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sereal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | sub serialiser { return( shift->_set_get_scalar( '_packing_method', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialiser: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 4 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 4 | *serializer = \&serialiser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | sub shmstat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shmstat: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | ▶ | my $shm = $self->_ipc_shared || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
$self->_ipc_shared
Truth table0%0/2
A
A= $self->_ipc_shared
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | return( $self->error( "No IPC::SharedMem object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $rv = $shm->stat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | return( $self->error( "Error with \$shm->stat: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 20 | ▶ | sub size { return( shift->_set_get_scalar( 'size', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | sub stat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stat: called CC=14 SCAR=37.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 5 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 5 | ▶ | my $obj = $self->_sem || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
$self->_sem
Truth table50%1/2
A
A= $self->_sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | return( $self->error( "No IPC::Semaphore object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 5 | my $id = $obj->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 5 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 5 | ▶ | if( @_ == 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 3 | my $sem = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 3 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 3 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 3 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 3 | $v = $obj->getval( $sem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 3 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | return( $self->error( "Error getting value for semaphore '$sem': $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 3 | ▶ | return( $self->error( "Error with \$sem->getval: $!" ) ) if( !defined( $v ) && $! ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $v and $!
MC/DC0%0/2
not defined $v and $!
not defined $v
$!
Truth table33%1/3
not(A) and B
A= not defined $vB= $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 3 | ▶ | return if( !defined( $v ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 3 | return( 0 + $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 2 | my( $sem, $val ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 2 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 2 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 2 | $rv = $obj->setval( $sem => $val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 2 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | return( $self->error( "Error setting value for semaphore '$sem': $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 2 | ▶ | return( $self->error( "Unable to semctl with semaphore id '$id', semaphore '$sem', SETVAL='", &IPC::SysV::SETVAL, "' and value='$val': $!" ) ) if( !defined( $rv ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 2 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | my $data = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | ▶ | if( wantarray() ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | my @sem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | @sem = $obj->getall; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | return( $self->error( "Error getting all semaphore values as an array: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | return( @sem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | my $stats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | $stats = $obj->stat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | return( $self->error( "Error getting a stat object for semaphore id $id: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | return( $self->error( "Unable to stat semaphore with id '$id': $!" ) ) if( !$stats ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | return( $stats ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | ▶ | sub storable { return( shift->_packing_method( 'storable' ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
storable: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | sub supported { return( $SYSV_SUPPORTED ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supported: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | sub unlock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlock: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 7 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 7 | ▶ | return(1) if( !$self->locked ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 5 | ▶ | my $sem = $self->_sem || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_sem || (return $self->error('No IPC::Semaphore object set. Have you opened the shared memory?'))
$self->_sem
Truth table50%1/2
A
A= $self->_sem
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | return( $self->error( "No IPC::Semaphore object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 5 | my $type = ( $self->locked | LOCK_UN ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 5 | ▶ | $type ^= LOCK_NB if( $type & LOCK_NB ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | # if( defined( $self->op( @{$SEMOP_ARGS->{ $type }} ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | # $self->locked(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 5 | ▶ | if( !defined( $self->op( @{$SEMOP_ARGS->{ $type }} ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # Failed to unlock semaphore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 5 | $self->locked(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 5 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | sub write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=37 SCAR=60.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 4 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 4 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 4 | ▶ | if( scalar( @_ ) == 1 && ref( $_[0] ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar @_ == 1 and ref $_[0]
MC/DC0%0/2
scalar @_ == 1 and ref $_[0]
scalar @_ == 1
ref $_[0]
Truth table33%1/3
A and B
A= scalar @_ == 1B= ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 4 | $data = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | $data = \join( '', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 4 | ▶ | my $shm = $self->_ipc_shared || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
MC/DC0%0/1
$self->_ipc_shared || (return $self->error('No IPC::SharedMem object set. Have you opened the shared memory?'))
$self->_ipc_shared
Truth table50%1/2
A
A= $self->_ipc_shared
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | return( $self->error( "No IPC::SharedMem object set. Have you opened the shared memory?" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 4 | my $id = $self->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 4 | ▶ | return( $self->error( "No shared memory id set yet. You must open the shared memory first to write." ) ) if( !defined( $id ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 4 | ▶ | my $size = int( $self->size() ) || SHM_BUFSIZ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
int $self->size || 65536
MC/DC0%0/1
int $self->size || 65536
int $self->size
Truth table50%1/2
A
A= int $self->size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 4 | my $packing = $self->_packing_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 4 | my $encoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 4 | ▶ | if( $packing eq 'json' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 4 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 4 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 4 | $encoded = $self->_encode_json( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 4 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | return( $self->error( "An error occured encoding data provided using $packing with base64 set to '", ( $self->{base64} // '' ), ": $@. Data was: '$data'" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | elsif( $packing eq 'cbor' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | $encoded = $self->serialise( $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | serialiser => 'CBOR::XS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | allow_sharing => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | ▶ | ( defined( $self->{base64} ) ? ( base64 => $self->{base64} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | return( $self->error( "An error occured encoding data provided using $packing with base64 set to '", ( $self->{base64} // '' ), ": $@. Data was: '$data'" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | ▶ | return( $self->error( "Unable to serialise ", CORE::length( $data ), " bytes of data using CBOR::XS with base64 set to '", ( $self->{base64} // '' ), ": ", $self->error ) ) if( !defined( $encoded ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | elsif( $packing eq 'sereal' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | ▶ | $self->_load_class( 'Sereal::Encoder' ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | my $const; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | $const = \&{"Sereal\::Encoder::SRL_ZLIB"} if( defined( &{"Sereal\::Encoder::SRL_ZLIB"} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | $encoded = $self->serialise( $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | serialiser => 'Sereal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | freeze_callbacks => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | ( defined( $const ) ? ( compress => $const->() ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | ▶ | ( defined( $self->{base64} ) ? ( base64 => $self->{base64} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | ▶ | return( $self->error( "An error occured encoding data provided using $packing with base64 set to '", ( $self->{base64} // '' ), ": $@. Data was: '$data'" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | return( $self->error( "Unable to serialise ", CORE::length( $data ), " bytes of data using Sereal with base64 set to '", ( $self->{base64} // '' ), ": ", $self->error ) ) if( !defined( $encoded ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | # Default to Storable::Improved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | # local $Storable::forgive_me = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | # $encoded = Storable::Improved::freeze( $data ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | $encoded = $self->serialise( $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | serialiser => 'Storable::Improved', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | ▶ | ( defined( $self->{base64} ) ? ( base64 => $self->{base64} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | ▶ | return( $self->error( "An error occured encoding data provided using $packing with base64 set to '", ( $self->{base64} // '' ), ": $@. Data was: '$data'" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | ▶ | return( $self->error( "Unable to serialise ", CORE::length( $data ), " bytes of data using Storable with base64 set to '", ( $self->{base64} // '' ), ": ", $self->error ) ) if( !defined( $encoded ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"base64"} // ""
MC/DC0%0/1
$self->{"base64"} // ""
$self->{"base64"}
Truth table0%0/2
A
A= $self->{"base64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | # Simple encapsulation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | # FYI: MG = Module::Generic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 4 | substr( $encoded, 0, 0, 'MG[' . length( $encoded ) . ']' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 4 | my $len = length( $encoded ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 4 | ▶ | if( $len > $size ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | return( $self->error( "Data to write are ${len} bytes long and exceed the maximum you have set of '$size'." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | # Ensure the shared memory segment is attached | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 4 | ▶ | unless( defined( $self->addr ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 4 | my $addr = shmat( $id, undef, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 4 | ▶ | if( !defined( $addr ) || ( Scalar::Util::looks_like_number( $addr ) && $addr == -1 ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $addr or &Scalar::Util::looks_like_number($addr) and $addr == -1
&Scalar::Util::looks_like_number($addr) and $addr == -1
MC/DC0%0/3
not defined $addr or &Scalar::Util::looks_like_number($addr) and $addr == -1
not defined $addr
&Scalar::Util::looks_like_number($addr)
$addr == -1
Truth table25%1/4
not(A) or B and C
A= not defined $addrB= &Scalar::Util::looks_like_number($addr)C= $addr == -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | return( $self->error( "Unable to attach to shared memory id '$id': $!" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 4 | $self->{addr} = $addr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 4 | ▶ | $self->lock( LOCK_EX ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | # my $rv = shmwrite( $id, $encoded, 0, $len ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | # return( $self->error( "Unable to write to shared memory id '$id' with ${len} bytes of data encoded and memory size of $size: $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 4 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 4 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 4 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 4 | $rv = $shm->write( $encoded, 0, $len ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 4 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | return( $self->error( "Error with \$shm->write: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 4 | ▶ | return( $self->error( "Unable to write to shared memory id '$id' with ${len} bytes of data encoded and memory size of $size: $!" ) ) if( !$rv ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 4 | $self->unlock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 4 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | sub _decode_json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_json: called CC=4 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 5 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 5 | my $data = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | # Nothing to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 5 | ▶ | return( $data ) if( !defined( $data ) || !CORE::length( $data ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $data and length $data
MC/DC0%0/2
defined $data and length $data
defined $data
length $data
Truth table33%1/3
A and B
A= defined $dataB= length $data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 5 | my $j = JSON->new->utf8->relaxed->allow_nonref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 5 | my $seen = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 5 | my $crawl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | $crawl = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=35.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 5 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 5 | my $type = Scalar::Util::reftype( $this ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 5 | ▶ | return( $this ) if( ( $type eq 'HASH' || $type eq 'ARRAY' ) && ++$seen->{ Scalar::Util::refaddr( $this ) } > 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$type eq "HASH" || $type eq "ARRAY" and ++$$seen{builtin::refaddr($this)} > 1
$type eq "HASH" or $type eq "ARRAY"
MC/DC0%0/3
$type eq "HASH" || $type eq "ARRAY" and ++$$seen{builtin::refaddr($this)} > 1
$type eq "HASH"
$type eq "ARRAY"
++$$seen{builtin::refaddr($this)} > 1
Truth table20%1/5
A or B and C
A= $type eq "HASH"B= $type eq "ARRAY"C= ++$$seen{builtin::refaddr($this)} > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 5 | ▶ | if( $type eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | # Found a former scalar reference, restore it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 5 | ▶ | if( CORE::exists( $this->{__scalar_gen_shm} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | return( \$this->{__scalar_gen_shm} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 5 | foreach my $k ( keys( %$this ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 12 | ▶ | next if( !ref( $this->{ $k } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | $this->{ $k } = $crawl->( $this->{ $k } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | elsif( $type eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | for( my $i = 0; $i < scalar( @$this ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | next if( !ref( $this->[$i] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | $this->[$i] = $crawl->( $this->[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 5 | return( $this ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 5 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 5 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 5 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 5 | my $decoded = $j->decode( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 5 | $result = $crawl->( $decoded ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 5 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | return( $self->error( "An error occurred while trying to decode JSON data: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 5 | return( $result ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | # Purpose of this method is to recursively check the given data and change scalar reference if they are anything else than 1 or 0, otherwise JSON would complain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | sub _encode_json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode_json: called CC=2 SCAR=10.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 4 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 4 | my $data = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 4 | my $seen = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 4 | my $crawl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | $crawl = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=15 SCAR=46.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 4 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 4 | my $type = Scalar::Util::reftype( $this ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | # Skip this reference if it is either hash or array and we have already seen it in order to avoid looping. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 4 | ▶ | return( $this ) if( ( $type eq 'HASH' || $type eq 'ARRAY' ) && ++$seen->{ Scalar::Util::refaddr( $this ) } > 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$type eq "HASH" || $type eq "ARRAY" and ++$$seen{builtin::refaddr($this)} > 1
$type eq "HASH" or $type eq "ARRAY"
MC/DC0%0/3
$type eq "HASH" || $type eq "ARRAY" and ++$$seen{builtin::refaddr($this)} > 1
$type eq "HASH"
$type eq "ARRAY"
++$$seen{builtin::refaddr($this)} > 1
Truth table20%1/5
A or B and C
A= $type eq "HASH"B= $type eq "ARRAY"C= ++$$seen{builtin::refaddr($this)} > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 4 | ▶ | if( $type eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 4 | foreach my $k ( keys( %$this ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 11 | ▶ | next if( !ref( $this->{ $k } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | $this->{ $k } = $crawl->( $this->{ $k } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | elsif( $type eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | ▶ | for( my $i = 0; $i < scalar( @$this ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | ▶ | next if( !ref( $this->[$i] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | $this->[$i] = $crawl->( $this->[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | elsif( $type eq 'SCALAR' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | # The only supported value by JSON for a scalar reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | ▶ | return( $this ) if( $$this eq "1" or $$this eq "0" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$$this eq 1 or $$this eq 0
MC/DC0%0/2
$$this eq 1 or $$this eq 0
$$this eq 1
$$this eq 0
Truth table0%0/3
A or B
A= $$this eq 1B= $$this eq 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | my $pkg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | ▶ | if( ( $pkg = Scalar::Util::blessed( $this ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | ▶ | if( overload::Method( $this => '""' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | $this = { __scalar_gen_shm => "$this", __package => $pkg }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | $this = { __scalar_gen_shm => $$this, __package => $pkg }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | $this = { __scalar_gen_shm => $$this }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 4 | return( $this ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 4 | my $ref = $crawl->( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 4 | my $j = JSON->new->utf8->relaxed->allow_nonref->convert_blessed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 4 | my $encoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 4 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 4 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 4 | $encoded = $j->encode( $ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 4 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | return( $self->error( "An error occurred while trying to JSON encode data: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 4 | return( $encoded ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 24 | ▶ | sub _ipc_shared { return( shift->_set_get_scalar( '_ipc_shared', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ipc_shared: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 15 | ▶ | sub _packing_method { return( shift->_set_get_scalar( '_packing_method', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_packing_method: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 22 | ▶ | sub _sem { return( shift->_set_get_scalar( '_sem', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sem: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | sub _str2key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 14 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_str2key: called CC=11 SCAR=29.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 14 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 14 | my $key = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 4 | ▶ | no strict 'subs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 14 | ▶ | if( !defined( $key ) || $key eq '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $key or $key eq ""
MC/DC0%0/2
not defined $key or $key eq ""
not defined $key
$key eq ""
Truth table33%1/3
not(A) or B
A= not defined $keyB= $key eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | return( &IPC::SysV::IPC_PRIVATE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 14 | my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 14 | ▶ | ( $key, $path ) = ref( $key ) eq 'ARRAY' ? @$key : ( $key, [getpwuid($>)]->[7] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 14 | ▶ | $path = [getpwuid($path)]->[7] if( defined( $path ) && $path =~ /^\d+$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $path and $path =~ /^\d+$/
MC/DC0%0/2
defined $path and $path =~ /^\d+$/
defined $path
$path =~ /^\d+$/
Truth table33%1/3
A and B
A= defined $pathB= $path =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 14 | ▶ | $path ||= File::Spec->rootdir(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$path ||= "File::Spec"->rootdir
MC/DC0%0/2
$path ||= "File::Spec"->rootdir
$path
"File::Spec"->rootdir
Truth table33%1/3
A ||= B
A= $pathB= "File::Spec"->rootdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 14 | ▶ | if( $key =~ /^\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | ▶ | my $id = &IPC::SysV::ftok( $path, $key ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&IPC::SysV::ftok($path, $key) || (return $self->error("Unable to get a key using IPC::SysV::ftok: $!"))
MC/DC0%0/1
&IPC::SysV::ftok($path, $key) || (return $self->error("Unable to get a key using IPC::SysV::ftok: $!"))
&IPC::SysV::ftok($path, $key)
Truth table0%0/2
A
A= &IPC::SysV::ftok($path, $key)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | return( $self->error( "Unable to get a key using IPC::SysV::ftok: $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | return( $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 14 | ▶ | $self->_load_class( 'Digest::SHA' ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | # ftok() only uses the low 8 bits of its project id, so reducing an arbitrary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | # string to a single project-id byte creates a very small key space and makes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | # collisions likely. Derive a stable positive 31-bit SysV key directly from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | # the SHA-1 digest instead. Include the path in the digest so array-form keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | # keep the path component as part of their identity. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 14 | my $seed = join( "\0", $path, $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 14 | my $hash = Digest::SHA::sha1( $seed ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 14 | my $val = unpack( 'N', substr( $hash, 0, 4 ) ) & 0x7fffffff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 14 | ▶ | $val = 1 if( !$val ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 14 | return( $val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | sub _verify_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 14 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_verify_key: called CC=10 SCAR=33.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 14 | my( $self, $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 14 | ▶ | if( !defined( $key ) || !length( $key // '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition40%2/5
defined $key && length($key // '')
$key // ""
MC/DC0%0/2
defined $key && length($key // '')
defined $key
$key
Truth table33%1/3
A && B
A= defined $keyB= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | # It's ok, _str2key will use IPC::SysV::IPC_PRIVATE then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | ▶ | elsif( !ref( $key ) || $self->_can_overload( $key => '""' ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
not ref $key or $self->_can_overload($key, "\"\"")
MC/DC0%0/2
not ref $key or $self->_can_overload($key, "\"\"")
not ref $key
$self->_can_overload($key, "\"\"")
Truth table33%1/3
not(A) or B
A= not ref $keyB= $self->_can_overload($key, "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 14 | $key = "$key"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 14 | ▶ | if( !CORE::length( $key // '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$key // ""
MC/DC0%0/1
$key // ""
$key
Truth table50%1/2
A
A= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | return( $self->error( "An empty key was provided." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | elsif( $self->_is_array( $key ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | # We use as-is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | return( $self->error( "Key must be a string, but I got '", $self->_str_val( $key // 'undef' ), "'" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$key // "undef"
MC/DC0%0/1
$key // "undef"
$key
Truth table0%0/2
A
A= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 14 | return( $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | sub DESTROY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=11 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | # <https://perldoc.perl.org/perlobj#Destructors> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 6 | CORE::local( $., $@, $!, $^E, $? ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 6 | ▶ | CORE::return if( Module::Generic::_in_global_destruction() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 6 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 6 | ▶ | CORE::return if( !CORE::defined( $self ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 6 | ▶ | CORE::return unless( $self->{_ipc_shared} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 2 | my $shm = $self->{_ipc_shared}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | # For non-object context, we need to call cleanup to ensure there is no leftover | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 2 | my $class = CORE::ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 2 | my $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 2 | $id = eval{ $shm->id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 2 | my $shem_repo = Module::Generic::Global->new( 'shem_repo' => $class, key => $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 2 | $shem_repo->cleanup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 2 | ▶ | if( CORE::defined( $id ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 2 | my $id2obj_repo = Module::Generic::Global->new( 'id2obj' => $class, key => $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 2 | $id2obj_repo->cleanup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 2 | ▶ | CORE::return if( !CORE::defined( $id ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 2 | ▶ | $self->unlock if( $self->locked ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 2 | $self->detach; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 2 | ▶ | if( $self->destroy ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | my $stat = $self->shmstat(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | # number of processes attached to the associated shared memory segment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | ▶ | if( CORE::defined( $stat ) && ( $stat->nattch() == 0 ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $stat and $stat->nattch == 0
MC/DC0%0/2
defined $stat and $stat->nattch == 0
defined $stat
$stat->nattch == 0
Truth table0%0/3
A and B
A= defined $statB= $stat->nattch == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | $self->remove; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | elsif( $self->destroy_semaphore ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | $self->remove_semaphore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | sub FREEZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FREEZE: called CC=7 SCAR=23.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 3 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 3 | ▶ | my $serialiser = CORE::shift( @_ ) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ // ""
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 3 | my $class = CORE::ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | # We skip 'owner' on purpose, since it represents the process ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 3 | my @props = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | base64 create destroy destroy_semaphore exclusive key mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | serial size _packing_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 3 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 3 | foreach my $prop ( @props ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 30 | ▶ | if( exists( $self->{ $prop } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 30 | $hash->{ $prop } = $self->{ $prop }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 3 | ▶ | $hash->{_was_opened} = $self->{_ipc_shared} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | # Return an array reference rather than a list so this works with Sereal and CBOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | # On or before Sereal version 4.023, Sereal did not support multiple values returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 3 | ▶ | if( $serialiser eq 'Sereal' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | require Sereal::Encoder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | require version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | ▶ | if( version->parse( Sereal::Encoder->VERSION ) <= version->parse( '4.023' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | CORE::return( [$class, $hash] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | # But Storable want a list with the first element being the serialised element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 3 | CORE::return( $class, $hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 3 | ▶ | sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | ▶ | sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | # NOTE: CBOR will call the THAW method with the stored classname as first argument, the constant string CBOR as second argument, and all values returned by FREEZE as remaining arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | # NOTE: Storable calls it with a blessed object it created followed with $cloning and any other arguments initially provided by STORABLE_freeze | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | sub THAW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
THAW: not called CC=23 SCAR=63.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | my( $self, undef, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | ▶ | my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1
ref $args[0] eq "ARRAY"
Truth table0%0/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | ▶ | my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref and ref $ref eq "ARRAY"
ref $self or $self
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref
ref $ref eq "ARRAY"
scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self
$self
Truth table0%0/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
Truth table0%0/3
A or B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | ▶ | my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | my $was_opened = CORE::delete( $hash->{_was_opened} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | # Storable pattern requires to modify the object it created rather than returning a new one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | ▶ | if( CORE::ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | foreach( CORE::keys( %$hash ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 0 | $self->{ $_ } = CORE::delete( $hash->{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | $new = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 0 | $new = CORE::bless( $hash => $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 0 | ▶ | if( $was_opened ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | ▶ | my $size = ( defined( $new->{size} ) && length( $new->{size} ) ) ? $new->{size} : SHM_BUFSIZ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $new->{"size"} and length $new->{"size"}
MC/DC0%0/2
defined $new->{"size"} and length $new->{"size"}
defined $new->{"size"}
length $new->{"size"}
Truth table0%0/3
A and B
A= defined $new->{"size"}B= length $new->{"size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | ▶ | my $flags = ( defined( $new->{flags} ) && length( $new->{flags} ) ) ? $new->{flags} : &IPC::SysV::S_IRWXU; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $new->{"flags"} and length $new->{"flags"}
MC/DC0%0/2
defined $new->{"flags"} and length $new->{"flags"}
defined $new->{"flags"}
length $new->{"flags"}
Truth table0%0/3
A and B
A= defined $new->{"flags"}B= length $new->{"flags"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | ▶ | $flags |= &IPC::SysV::IPC_CREAT if( defined( $new->{create} ) && $new->{create} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $new->{"create"} and $new->{"create"}
MC/DC0%0/2
defined $new->{"create"} and $new->{"create"}
defined $new->{"create"}
$new->{"create"}
Truth table0%0/3
A and B
A= defined $new->{"create"}B= $new->{"create"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | my $key = $new->{key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | my $shm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | ▶ | if( defined( $key ) && length( $key ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $key and length $key
MC/DC0%0/2
defined $key and length $key
defined $key
length $key
Truth table0%0/3
A and B
A= defined $keyB= length $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | $key = $self->_str2key( $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | $shm = IPC::SharedMem->new( $key, $size, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | $shm = IPC::SharedMem->new( &IPC::SysV::IPC_PRIVATE, $size, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | $new->{_ipc_shared} = $shm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | return( $self->error( "Error creating a new IPC::SharedMem object: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | my $sem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 0 | $sem = IPC::Semaphore->new( $key, 3, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 0 | return( $self->error( "Error creating a new IPC::Semaphore object: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | ▶ | if( !defined( $sem ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 0 | ▶ | return( $self->error( "Unable to create semaphore with key \"", ( $key // '' ), "\" and flags \"$flags\": $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$key // ""
MC/DC0%0/1
$key // ""
$key
Truth table0%0/2
A
A= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 0 | $new->{_sem} = $sem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | CORE::return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | # NOTE: END | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | # END | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | # my $shem_repo = Module::Generic::Global->new( 'shem_repo' => __PACKAGE__, key => __PACKAGE__ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | # $shem_repo->lock; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | # my $all_shem = $shem_repo->get // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | # foreach my $id ( @$all_shem ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | # my $id2obj_repo = Module::Generic::Global->new( 'id2obj' => __PACKAGE__, key => $id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | # my $s = $id2obj_repo->get || next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | # next if( $s->removed || !$s->id || !$s->destroy ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | # $s->detach; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | # $s->remove; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | # $shem_repo->unlock; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | # $shem_repo->remove; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | # }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||