Skip to content

Commit e2f3501

Browse files
committed
For WOL feature, improve error handling #402
1 parent 7d6e68c commit e2f3501

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/Libki/Clients.pm

Lines changed: 7 additions & 2 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';
@@ -23,7 +22,13 @@ sub wakeonlan {
2322
my $socket = new IO::Socket::INET( Proto => 'udp' )
2423
or $c->log()->fatal("ERROR in Socket Creation : $!\n");
2524

26-
if ($socket) {
25+
my $socket = new IO::Socket::INET( Proto => 'udp' )
26+
or do {
27+
$c->log()->error("Socket Creation failed: $!\n");
28+
$success = 0;
29+
};
30+
31+
if ( $success && $socket ) {
2732
setsockopt( $socket, SOL_SOCKET, SO_BROADCAST, 1 );
2833

2934
foreach my $mac_address (@mac_addresses) {

0 commit comments

Comments
 (0)