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   30 use strict;
  5         18  
  5         135  
4 5     5   25 use warnings;
  5         10  
  5         107  
5              
6 5     5   649 use Socket ();
  5         3636  
  5         100  
7              
8 5     5   2190 use IO::SigGuard ('send');
  5         2839  
  5         33  
9              
10             # No support for this (POSIX-standard!) constant in macOS or Solaris.
11 5   50 5   2634 use constant _MSG_NOSIGNAL => eval { Socket::MSG_NOSIGNAL() } || 0;
  5         11  
  5         14  
12              
13             sub send_nosignal {
14              
15             # This is for OSes that don’t define this constant:
16 3     3 0 8 local $SIG{'PIPE'} = 'IGNORE' if !_MSG_NOSIGNAL();
17              
18 3         15 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;