Skip to content

Commit a98ada9

Browse files
committed
For WOL feature, improve error handling #402
1 parent e71e015 commit a98ada9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Libki/Clients.pm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Send a magic packet for every MAC address in the ClientMACAddresses setting.
1111

1212
sub wakeonlan {
1313
my ($c) = @_;
14-
1514
my $success = 1;
1615

1716
my $host = $c->setting('WOLHost') || '255.255.255.255';
@@ -21,9 +20,12 @@ sub wakeonlan {
2120
my @mac_addresses = get_wol_mac_addresses($c);
2221

2322
my $socket = new IO::Socket::INET( Proto => 'udp' )
24-
or $c->log()->fatal("ERROR in Socket Creation : $!\n");
23+
or do {
24+
$c->log()->error("Socket Creation failed: $!\n");
25+
$success = 0;
26+
};
2527

26-
if ($socket) {
28+
if ( $success && $socket ) {
2729
setsockopt( $socket, SOL_SOCKET, SO_BROADCAST, 1 );
2830

2931
foreach my $mac_address (@mac_addresses) {

0 commit comments

Comments
 (0)