perfsonar-dev - [pS-dev] [GEANT/SA2/SA2T3-OPPD] r664 - in branches/perfsonar-oppd-new-architect: bin lib/perfSONAR
Subject: perfsonar development work
List archive
[pS-dev] [GEANT/SA2/SA2T3-OPPD] r664 - in branches/perfsonar-oppd-new-architect: bin lib/perfSONAR
Chronological Thread
- From:
- To:
- Subject: [pS-dev] [GEANT/SA2/SA2T3-OPPD] r664 - in branches/perfsonar-oppd-new-architect: bin lib/perfSONAR
- Date: Fri, 12 Nov 2010 07:43:16 GMT
Author: dfn.calim
Date: 2010-11-12 07:43:16 +0000 (Fri, 12 Nov 2010)
New Revision: 664
Modified:
branches/perfsonar-oppd-new-architect/bin/oppd.pl
branches/perfsonar-oppd-new-architect/lib/perfSONAR/MP.pm
Log:
Added tool check in module MP
Modified: branches/perfsonar-oppd-new-architect/bin/oppd.pl
===================================================================
--- branches/perfsonar-oppd-new-architect/bin/oppd.pl 2010-11-11 07:38:52
UTC (rev 663)
+++ branches/perfsonar-oppd-new-architect/bin/oppd.pl 2010-11-12 07:43:16
UTC (rev 664)
@@ -579,7 +579,6 @@
#
#TODO: enable tracing output for our own SOAP implementation
-# Use Log::Dispatcher for debug/error handling somehow?
my $http_daemon;
my $errno = 0;
@@ -645,62 +644,7 @@
}
}
-
#
-# start process for selftest functionality
-#
-
-#TODO rework fork code completely!!
-#TODO add more messages and checks
-
-#selftesting functions are defined in plugin modules and
-#can be configured in oppd.conf per service
-=cut
-my @testservices;
-
-foreach my $service (keys %services){
- if ($services{$service}{"selftest"}){
- push @testservices, $service;
- } else {
- $log->log(
- level => "notice", service => $service,
- message => "No selftests specified for $service."
- );
- }
-}
-
-while (my $service = pop @testservices){
- foreach my $test (keys %{$services{$service}{"selftest"}}){
- my $pid = fork();
- defined($pid) or $log->log(
- level => "warning", service => $service,
- message => "Could not fork selftest process $test for module $service:
$!"
- );
- #last if ($pid!=0);
- if ($pid==0){ #child process, do selftest
- $SIG{INT} = $SIG{TERM} = sub {
- $log->log(
- level => "notice", service => $service,
- message => "Signal caught - exiting selftest process $test for
$service"
- );
- exit 1;
- };
- # do not call REAPER on SIGCHLD and avoid zombie children
- $SIG{CHLD} = 'IGNORE';
- while (1){
- my $result = $services{$service}->{handler}->selftest($test);
- $log->log(
- level => "notice", service => $service,
- message => "selftesting service $service: $test returned $result"
- );
- sleep($services{$service}{"selftest"}{$test});
- }
- }
- }
-}
-=cut
-
-#
# Accept connections
#
@@ -735,7 +679,7 @@
$logger->info("Incoming connection from $peer_str");
if (scalar(keys %connections)+1 > $max_conn) {
my $msg = "Too many connections";
- $logger->trace("$msg - closing connection to $peer_str");
+ $logger->error("$msg - closing connection to $peer_str");
$conn->send_error(503, $msg); #RC_SERVICE_NOT_AVAILABLE
close_socket($conn, "Error closing rejected connection");
next;
@@ -815,8 +759,6 @@
if ($auth){
perfSONAR::Auth::authenticate($soap_message, $nmwg_message, $as_url);
}
-
- $logger->debug("Request:\n".$soap_message->header);
#Create a DataStruct
my $ds = perfSONAR::DataStruct->new($soap_message->uri,
$nmwg_message);
@@ -835,7 +777,7 @@
#TODO what about header?
$soap_message->body($nmwg_response->as_dom()->documentElement);
$response->content($soap_message->as_string);
- };
+ }; #End eval
if (my $eval_err = $@) {
$log->info("Processing SOAP request failed: $eval_err");
$response->content(
@@ -846,8 +788,7 @@
)->as_string
);
}
- $logger->debug("Sending response");
- $logger->debug("Response:\n".$response->content());
+ $logger->debug("Sending response:\n".$response->content());
$conn->send_response($response);
$logger->debug("Setting connection timeout to $conn_timeout");
# TODO: timeout() is broken with HTTP::Daemon::SSL
@@ -999,11 +940,13 @@
# - Respawn LS registration process.
#
sub REAPER { # see also 'man perlipc'
- local $!; # waitpid() and others may overwrite current error
- while ((my $pid = waitpid(-1,WNOHANG)) > 0) {
- my $reason = $? ? " with exit code $?" : "";
- if (exists $connections{$pid}) {
- $logger->debug(
+ # don't change $! and $? outside handler
+ local ($!,$?);
+
+ while ((my $pid = waitpid(-1,WNOHANG)) > 0) {
+ my $reason = $? ? " with exit code $?" : "";
+ if (exists $connections{$pid}) {
+ $logger->info(
"Connection process $pid for connection $connections{$pid} exited"
. $reason
);
Modified: branches/perfsonar-oppd-new-architect/lib/perfSONAR/MP.pm
===================================================================
--- branches/perfsonar-oppd-new-architect/lib/perfSONAR/MP.pm 2010-11-11
07:38:52 UTC (rev 663)
+++ branches/perfsonar-oppd-new-architect/lib/perfSONAR/MP.pm 2010-11-12
07:43:16 UTC (rev 664)
@@ -48,6 +48,7 @@
use Log::Log4perl qw(get_logger);
use IPC::Run qw( run timeout start finish pump);
use IO::Pty;
+use POSIX ":sys_wait_h";
use base qw(perfSONAR::Echo);
=head1 Methods:
@@ -125,13 +126,28 @@
if ($commandline[0] eq "ERROR") {
$$ds->{ERROROCCUR} = 1;
- $$ds->{PARAMS}->{$id}->{MRESULT} =
\@commandline;
+ $$ds->{SERVICE}->{DATA}->{$id}->{MRESULT} =
\@commandline;
return;
}
#Start commandline
#Get tool for commandline
my $tool = $$ds->{SERVICES}->{$$ds->{SERVICE}->{NAME}}->{tool};
+ #first check if tool is available
+ my $ret = `which $tool 2>/dev/null`;
+ if ( length $ret <= 0 ){
+ $$ds->{ERROROCCUR} = 1;
+ my $et = "error.$tool.mp";
+ my @errmsg;
+ push @errmsg, "ERROR:";
+ push @errmsg, "command:", $tool;
+ push @errmsg, "not found";
+ $self->{LOGGER}->error("@errmsg");
+ push @errmsg, $et;
+ $$ds->{SERVICE}->{DATA}->{$id}->{MRESULT} =
\@errmsg;
+ return;
+ }
+
$self->{LOGGER}->info("Service: $$ds->{SERVICE}->{NAME} called with
command: $tool @commandline");
#Define pipes
- [pS-dev] [GEANT/SA2/SA2T3-OPPD] r664 - in branches/perfsonar-oppd-new-architect: bin lib/perfSONAR, svn-noreply, 11/12/2010
Archive powered by MHonArc 2.6.16.