|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # (c) Jan Gehring   | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Rex::Shared::Var::Common;  | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
63
 | 
 
 | 
 
 | 
  
63
  
 | 
 
 | 
956
 | 
 use v5.12.5;  | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
263
 | 
    | 
| 
8
 | 
63
 | 
 
 | 
 
 | 
  
63
  
 | 
 
 | 
356
 | 
 use warnings;  | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
129
 | 
    | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2273
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 require Exporter;  | 
| 
11
 | 
63
 | 
 
 | 
 
 | 
  
63
  
 | 
 
 | 
425
 | 
 use base qw/Exporter/;  | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
216
 | 
    | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7446
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @EXPORT_OK = qw/__lock __store __retrieve/;  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '1.14.2.3'; # TRIAL VERSION  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
16
 | 
63
 | 
 
 | 
 
 | 
  
63
  
 | 
 
 | 
513
 | 
 use Fcntl qw(:DEFAULT :flock);  | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
206
 | 
    | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
32581
 | 
    | 
| 
17
 | 
63
 | 
 
 | 
 
 | 
  
63
  
 | 
 
 | 
5196
 | 
 use Storable;  | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
183720
 | 
    | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4057
 | 
    | 
| 
18
 | 
63
 | 
 
 | 
 
 | 
  
63
  
 | 
 
 | 
526
 | 
 use File::Spec;  | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
156
 | 
    | 
| 
 
 | 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2981
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # $PARENT_PID gets set when Rex starts.  This value remains the same after the  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # process forks.  So $PARENT_PID is always the pid of the parent process.  $$  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # however is always the pid of the current process.  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $PARENT_PID = $$;  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $FILE = File::Spec->catfile( File::Spec->tmpdir(), "vars.db.$PARENT_PID" );  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $LOCK_FILE =  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   File::Spec->catfile( File::Spec->tmpdir(), "vars.db.lock.$PARENT_PID" );  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub __lock {  | 
| 
29
 | 
1120
 | 
  
 50
  
 | 
 
 | 
  
1120
  
 | 
 
 | 
60606
 | 
   sysopen( my $dblock, $LOCK_FILE, O_RDONLY | O_CREAT ) or die($!);  | 
| 
30
 | 
1120
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
27139
 | 
   flock( $dblock, LOCK_EX )                             or die($!);  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
32
 | 
1120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5529
 | 
   my $ret = $_[0]->();  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
34
 | 
1120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
164184
 | 
   close($dblock);  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
1120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14166
 | 
   return $ret;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub __store {  | 
| 
40
 | 
292
 | 
 
 | 
 
 | 
  
292
  
 | 
 
 | 
699
 | 
   my $ref = shift;  | 
| 
41
 | 
292
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1529
 | 
   store( $ref, $FILE );  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub __retrieve {  | 
| 
45
 | 
1120
 | 
  
100
  
 | 
 
 | 
  
1120
  
 | 
 
 | 
15609
 | 
   return {} unless -f $FILE;  | 
| 
46
 | 
1102
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6700
 | 
   return retrieve($FILE);  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub END {  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   # return if we exiting a child process  | 
| 
53
 | 
63
 | 
  
100
  
 | 
 
 | 
  
63
  
 | 
 
 | 
46255
 | 
   return unless $$ eq $PARENT_PID;  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   # we are exiting the master process  | 
| 
56
 | 
28
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
4194
 | 
   unlink $FILE      if -f $FILE;  | 
| 
57
 | 
28
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
2739
 | 
   unlink $LOCK_FILE if -f $LOCK_FILE;  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  |