Changeset 413

Show
Ignore:
Timestamp:
01/02/07 22:35:16 (6 years ago)
Author:
lincoln
Message:

seperate out call_prog's overloading of $retval into two variables.
this was causing expressions which expected a numeric $retval to succeed
where they shouldn't have.

e.g. a shepherd.log from a user indicated shepherd was accepting the output from a failed plugin even though it shouldn't have:

SHEPHERD: Using postprocessor: augment_timezone
SHEPHERD: Excuting command: /home/mythtv/.shepherd/postprocessors/augment_timezone/augment_timezone --region 73 --channels_file /home/mythtv/.shepherd/channels.conf --output /home/mythtv/.shepherd/postprocessors/augment_timezone/output.xmltv --days 7 /home/mythtv/.shepherd/reconcilers/reconciler_mk2/output.xmltv

:::::: Output from augment_timezone
: adjust_timezone v0.04
: Not a SCALAR reference at /home/mythtv/.shepherd/postprocessors/augment_timezone/augment_timezone line 110.
:::::: End output from augment_timezone

SHEPHERD: Warning: plugin 'augment_timezone' output file '/home/mythtv/.shepherd/postprocessors/augment_timezone/output.xmltv' does not exist
SHEPHERD: accepting output from postprocessor augment_timezone, feeding it into next stage

whereas it should have rejected it up-front.

resolves bugs introduced in [401], [406] and [410].

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/shepherd

    r410 r413  
    22 
    33my $progname = 'shepherd'; 
    4 my $version = '0.4.28'; 
     4my $version = '0.4.29'; 
    55 
    66# tv_grab_au 
     
    450450     
    451451    chdir($ldir); 
    452     my ($result,$test_output) = call_prog($proggy, $progname." $opt_ready"." 2>&1",1,1,0); 
     452    my ($result,$resultmsg,$test_output) = call_prog($proggy, $progname." $opt_ready"." 2>&1",1,1,0); 
    453453    chdir ($CWD); 
    454454 
     
    465465 
    466466        # set proggy status accordingly 
    467         my ($res, $reason) = split(/:/,$result); 
    468467        $statusmsg = sprintf "FAILED (return code %d%s) on %s", 
    469             $res, 
    470             ($reason eq "" ? "" : ", reason '$reason'"), 
     468            $result, 
     469            ($resultmsg eq "" ? "" : ", '$resultmsg'"), 
    471470            POSIX::strftime("%a%d%b%y", localtime(time)); 
    472471 
     
    937936    if (!(open(PROG,"$prog 2>&1|"))) { 
    938937        &log("warning: couldn't exec $component as \"$prog\": $!\n"); 
    939         return(-1,$prog_output); 
     938        return(-1,"open failed",$prog_output); 
    940939    } 
    941940 
     
    972971    if ($? == -1) { 
    973972        &log("Failed to execute $component: $!\n"); 
    974         return ("-1:Failed to execute",$prog_output); 
     973        return (-1,"Failed to execute",$prog_output); 
    975974    } 
    976975    if ($msg) 
     
    985984        &log((sprintf "%s died with signal %d, %s coredump\n", 
    986985             ucfirst($component), ($? & 127),  (($? & 128) ? "with" : "without"))); 
    987         return sprintf("%d:Died:%s", ($? & 127), $msg); 
     986        return (($? & 127), "Died:$msg", $prog_output); 
    988987    }  
    989988    &log((sprintf "%s exited with value %d\n", ucfirst($component), ($? >> 8))) if ($debug); 
    990989 
    991     return (0,$prog_output) unless ($? >> 8); 
    992     return (sprintf("%d:%s", ($? >> 8), $msg),$prog_output); 
     990    return (0,"",$prog_output) unless ($? >> 8); 
     991    return (($? >> 8), $msg, $prog_output); 
    993992} 
    994993 
     
    17691768 
    17701769        my $retval = 0; 
     1770        my $msg; 
    17711771        my $component_start = time; 
    17721772        if ((defined $opt->{dontcallgrabbers}) && ($opt->{dontcallgrabbers})) { 
     
    17761776            &log("SHEPHERD: Excuting command: $comm\n"); 
    17771777            chdir "$CWD/grabbers/$grabber/"; 
    1778             $retval = call_prog($grabber,$comm,0,(query_config($grabber,'max_runtime')*60)); 
     1778            ($retval,$msg) = call_prog($grabber,$comm,0,(query_config($grabber,'max_runtime')*60)); 
    17791779            chdir $CWD; 
    17801780        } 
     
    17821782 
    17831783        if ($retval) { 
    1784             my ($code, $msg) = split(/:/, $retval); 
    1785             &log("Grabber exited with non-zero code $code: assuming it failed.\n" . 
     1784            &log("Grabber exited with non-zero code $retval: assuming it failed.\n" . 
    17861785                 "Last message: \"$msg\"\n"); 
    1787             $components->{$grabber}->{laststatus} = "Failed (code $code)"; 
     1786            $components->{$grabber}->{laststatus} = "Failed (code $retval)"; 
    17881787            $components->{$grabber}->{consecutive_failures}++; 
    1789             &add_pending_message($grabber,"FAIL", $retval, $component_start, $component_duration,  
     1788            &add_pending_message($grabber,"FAIL", $retval.":".$msg, $component_start, $component_duration,  
    17901789                $components->{$grabber}->{ver}, $components->{$grabber}->{consecutive_failures}); 
    17911790            next; 
     
    30393038    my $dir = sprintf "%s/%ss/%s/",$CWD,$data_processor_type,$data_processor_name; 
    30403039    chdir $dir; 
    3041     my $retval = call_prog($data_processor_name,$comm,0,(query_config($data_processor_name,'max_runtime')*60)); 
     3040    my ($retval,$msg) = call_prog($data_processor_name,$comm,0,(query_config($data_processor_name,'max_runtime')*60)); 
    30423041    chdir $CWD; 
    30433042    my $component_duration = time - $component_start; 
    30443043 
    30453044    if ($retval) { 
    3046         my ($code, $msg) = split(/:/, $retval); 
    3047         &log("$data_processor_type exited with non-zero code $code: assuming it failed.\n" . 
     3045        &log("$data_processor_type exited with non-zero code $retval: assuming it failed.\n" . 
    30483046             "Last message: $msg\n"); 
    3049         $components->{$data_processor_name}->{laststatus} = "Failed ($code)"; 
     3047        $components->{$data_processor_name}->{laststatus} = "Failed ($retval)"; 
    30503048        $components->{$data_processor_name}->{consecutive_failures}++; 
    3051         &add_pending_message($data_processor_name,"FAIL", $retval, $component_start, $component_duration, 
     3049        &add_pending_message($data_processor_name,"FAIL", $retval.":".$msg, $component_start, $component_duration, 
    30523050            $components->{$data_processor_name}->{ver}, $components->{$data_processor_name}->{consecutive_failures}); 
    30533051        return 0; 
     
    30703068    # process and analyze it! 
    30713069    &soak_up_data($data_processor_name, $output, $data_processor_type); 
    3072     my $have_all_data = &analyze_plugin_data("$data_processor_type $data_processor_name",0,$data_processor_name); 
     3070 
     3071    my $have_all_data = 0; 
     3072    if ((defined $plugin_data->{$data_processor_name}) && 
     3073        (defined $plugin_data->{$data_processor_name}->{valid})) { 
     3074        $have_all_data = &analyze_plugin_data("$data_processor_type $data_processor_name",0,$data_processor_name); 
     3075    } 
    30733076 
    30743077    if ($have_all_data) { 
     
    30823085        $components->{$data_processor_name}->{laststatus} = "missing data: ".$plugin_data->{$data_processor_name}->{laststatus}; 
    30833086        $components->{$data_processor_name}->{consecutive_failures}++; 
    3084         &add_pending_message($data_processor_name,"FAIL", $retval, $component_start, $component_duration, 
     3087        &add_pending_message($data_processor_name,"FAIL", $retval.":".$msg, $component_start, $component_duration, 
    30853088            $components->{$data_processor_name}->{ver}, $components->{$data_processor_name}->{consecutive_failures}); 
    30863089    } 
  • status

    r411 r413  
    1 application     shepherd            0.4.28 
     1application     shepherd            0.4.29 
    22grabber         yahoo7widget        1.71 
    33grabber         rex                 3.3.8