File Coverage

blib/lib/Protocol/DBus/Socket.pm
Criterion Covered Total %
statement 17 23 73.9
branch 0 4 0.0
condition 1 2 50.0
subroutine 6 7 85.7
pod 0 2 0.0
total 24 38 63.1


line stmt bran cond sub pod time code
1             package Protocol::DBus::Socket;
2              
3 12     12   147 use strict;
  12         68  
  12         288  
4 12     12   55 use warnings;
  12         15  
  12         260  
5              
6 12     12   3253 use Socket ();
  12         21083  
  12         338  
7              
8 12     12   4187 use IO::SigGuard ('send');
  12         3653  
  12         63  
9              
10             # No support for this (POSIX-standard!) constant in macOS or Solaris.
11 12   50 12   5158 use constant _MSG_NOSIGNAL => eval { Socket::MSG_NOSIGNAL() } || 0;
  12         25  
  12         16  
12              
13             sub send_nosignal {
14              
15             # This is for OSes that don’t define this constant:
16 6     6 0 17 local $SIG{'PIPE'} = 'IGNORE' if !_MSG_NOSIGNAL();
17              
18 6         56 return IO::SigGuard::send( $_[0], $_[1], $_[2] | _MSG_NOSIGNAL() );
19             }
20              
21             my $sent;
22              
23             sub sendmsg_nosignal {
24              
25             # This is for OSes that don’t define this constant:
26 0     0 0   local $SIG{'PIPE'} = 'IGNORE' if !_MSG_NOSIGNAL();
27              
28             SEND: {
29 0           $sent = Socket::MsgHdr::sendmsg( $_[0], $_[1], $_[2] | _MSG_NOSIGNAL() );
  0            
30 0 0         if (!defined $sent) {
31 0 0         redo SEND if $!{'EINTR'};
32             }
33             }
34              
35 0           return $sent;
36             }
37              
38             1;