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 5     5   101 use strict;
  5         21  
  5         147  
4 5     5   22 use warnings;
  5         10  
  5         224  
5              
6 5     5   653 use Socket ();
  5         3714  
  5         120  
7              
8 5     5   2312 use IO::SigGuard ('send');
  5         2870  
  5         33  
9              
10             # No support for this (POSIX-standard!) constant in macOS or Solaris.
11 5   50 5   2593 use constant _MSG_NOSIGNAL => eval { Socket::MSG_NOSIGNAL() } || 0;
  5         15  
  5         9  
12              
13             sub send_nosignal {
14              
15             # This is for OSes that don’t define this constant:
16 3     3 0 7 local $SIG{'PIPE'} = 'IGNORE' if !_MSG_NOSIGNAL();
17              
18 3         19 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;