summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAndrew Gaffney <agaffney@gentoo.org>2007-12-30 02:23:53 +0000
committerAndrew Gaffney <agaffney@gentoo.org>2007-12-30 02:23:53 +0000
commit9f5ba833bb3718b5ed61243fbd88c081b2cc5564 (patch)
treef53591dfc63977cae76698d8c264f1ef00b07138 /client
parentrelative config file location (diff)
downloadscire-9f5ba833bb3718b5ed61243fbd88c081b2cc5564.tar.gz
scire-9f5ba833bb3718b5ed61243fbd88c081b2cc5564.tar.bz2
scire-9f5ba833bb3718b5ed61243fbd88c081b2cc5564.zip
add END block and clean up errors
svn path=/branches/new-fu/; revision=276
Diffstat (limited to 'client')
-rwxr-xr-xclient/scireclient.pl23
1 files changed, 15 insertions, 8 deletions
diff --git a/client/scireclient.pl b/client/scireclient.pl
index d7843bc..59ca042 100755
--- a/client/scireclient.pl
+++ b/client/scireclient.pl
@@ -10,11 +10,12 @@ use Getopt::Long;
use Data::Dumper;
use File::Path;
#use Net::SSH::Perl::Key;
-
+use POSIX ":sys_wait_h";
my $SCIRE_CONFIG_FILE = '../etc/scire.conf'; #will be /etc/scire.conf when released.
my %conf;
my ($SERVER_STDOUT, $SERVER_STDIN);
+my $connection_pid;
run_main();
@@ -47,7 +48,8 @@ sub run_main {
my @existing_jobs = scan_jobs_dir();
#4. Fetch the jobs list
get_jobs(@existing_jobs);
- #5. ?
+ #5. ???
+ #6. Profit!
}
sub parse_command_line {
@@ -93,7 +95,6 @@ sub send_command {
#FIXME WE NEED A TIMEOUT HERE OF SOME SORT!!
#if the server doesn't give you a newline this just hangs!
my $response = <SERVER_STDOUT>;
-# my $response = get_response();
return $response;
}
@@ -118,7 +119,7 @@ sub create_connection {
# to STDERR:
# open2: exec of ../server/scireserver.pl failed at ./scireclient.pl line 116
my $connection_command = shift;
- my $pid = open2(*SERVER_STDOUT, *SERVER_STDIN, $connection_command);
+ $connection_pid = open2(*SERVER_STDOUT, *SERVER_STDIN, $connection_command);
}
sub build_connection_command {
@@ -164,7 +165,7 @@ sub register_client {
my $mac = "00:11:22:33:44:55";
my $ip = "192.168.2.3";
my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip));
- die "Could not register client $mac w/ ip $ip. got $response" if (! defined $status or $status ne "OK");
+ die "Could not register client $mac w/ ip $ip. Got: $message" if (! defined $status or $status ne "OK");
debug("Client registered. Status is pending.\n");
}
@@ -179,7 +180,7 @@ sub identify_client {
my $fingerprint = "124567890";
my ($status, $message) = parse_response(send_command("IDENTIFY", $fingerprint));
unless (defined $status && $status eq "OK") {
- print "Could not identify to server: $response\n";
+ print "Could not identify to server: $message\n";
return 0;
}
debug("Client identified\n");
@@ -190,7 +191,7 @@ sub get_jobs {
my @existing_jobs = @_;
my ($status, $message) = parse_response(send_command("GET_JOBS", @existing_jobs));
unless (defined $status && $status eq "OK") {
- print "Could not get jobs list from server: $response\n";
+ print "Could not get jobs list from server: $message\n";
return 0;
}
my $jobs = $2;
@@ -203,7 +204,7 @@ sub get_jobs {
next;
};
# XXX: Modify this to fetch a file instead
- print JOBFILE parse_response($resp);
+# print JOBFILE parse_response($resp);
close(JOBFILE);
debug("Fetched job $job \n");
}
@@ -242,3 +243,9 @@ sub debug {
print STDERR $msg;
}
}
+
+END {
+ while(waitpid($connection_pid, WNOHANG)) {
+ kill($connection_pid);
+ }
+}