From 0775b0707c76fceef69cd3c4c61b786b6e9a269c Mon Sep 17 00:00:00 2001 From: Florian Asche Date: Thu, 27 Mar 2014 00:08:50 +0100 Subject: [PATCH] Refs #5389: Fix Errorhandeling --- apps/hddtemp/mode/listdrives.pm | 9 +++++++-- apps/hddtemp/mode/temperature.pm | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/hddtemp/mode/listdrives.pm b/apps/hddtemp/mode/listdrives.pm index 8bf828fdf..4e2f5c311 100644 --- a/apps/hddtemp/mode/listdrives.pm +++ b/apps/hddtemp/mode/listdrives.pm @@ -53,7 +53,7 @@ sub new { { "hostname:s" => { name => 'hostname' }, "port:s" => { name => 'port', default => '7634' }, - "timeout:s" => { name => 'timeout', default => '1' }, + "timeout:s" => { name => 'timeout', default => '10' }, "filter-name:s" => { name => 'filter_name', }, }); @@ -80,8 +80,13 @@ sub manage_selection { PeerAddr => $self->{option_results}->{hostname}, PeerPort => $self->{option_results}->{port}, Timeout => $self->{option_results}->{timeout}, - ) || $self->{output}->add_option_msg(short_msg => "Could not connect.") ; $self->{output}->option_exit(); + ); + if (!defined($oSocketConn)) { + $self->{output}->add_option_msg(short_msg => "Could not connect."); + $self->{output}->option_exit(); + } + #|/dev/sda|SD280813AS|35|C|#|/dev/sdb|ST2000CD005-1CH134|35|C| my $_ = <$oSocketConn>; diff --git a/apps/hddtemp/mode/temperature.pm b/apps/hddtemp/mode/temperature.pm index 36548a8b4..829b5b17d 100644 --- a/apps/hddtemp/mode/temperature.pm +++ b/apps/hddtemp/mode/temperature.pm @@ -90,7 +90,12 @@ sub manage_selection { PeerAddr => $self->{option_results}->{hostname}, PeerPort => $self->{option_results}->{port}, Timeout => $self->{option_results}->{timeout}, - ) || $self->{output}->add_option_msg(short_msg => "Could not connect.") ; $self->{output}->option_exit(); + ); + + if (!defined($oSocketConn)) { + $self->{output}->add_option_msg(short_msg => "Could not connect."); + $self->{output}->option_exit(); + } #|/dev/sda|SD280813AS|35|C|#|/dev/sdb|ST2000CD005-1CH134|35|C|