Changeset 1444

Show
Ignore:
Timestamp:
04/03/08 15:34:52 (4 months ago)
Author:
kindlund
Message:

Removed excessive watchdog code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/kindlund-simpler_agent/bin/StartAgent.pl

    r1413 r1444  
    2121our $URL = HoneyClient::Agent->init(); 
    2222 
    23 our $agentState = undef; 
    24 my $tempState = undef; 
    25 our $faultDetected = 0; 
    26  
    2723print "URL: " . $URL. "\n"; 
    2824 
    29 sub _watchdogFaultHandler { 
    30  
    31     # Extract arguments. 
    32     my ($class, $res) = @_; 
    33  
    34     # Construct error message. 
    35     # Figure out if the error occurred in transport or over 
    36     # on the other side. 
    37     my $errMsg = $class->transport->status; # Assume transport error. 
    38  
    39     if (ref $res) { 
    40         $errMsg = $res->faultcode . ": ".  $res->faultstring . "\n"; 
    41     } 
    42  
    43     if (!$faultDetected) { 
    44         $LOG->error("Watchdog fault detected, recovering Agent daemon."); 
    45         $faultDetected = 1; 
    46     } 
    47     # XXX: Reenable this, eventually. 
    48     $LOG->error(__PACKAGE__ . "->_watchdogFaultHandler(): Error occurred during processing.\n" . $errMsg); 
    49     Carp::carp __PACKAGE__ . "->_watchdogFaultHandler(): Error occurred during processing.\n" . $errMsg; 
    50  
    51  
    52     # Regardless of the error, destroy the Agent process and reinitialize it. 
    53     # XXX: Sanity check this, eventually. 
    54     HoneyClient::Agent->destroy(); 
    55  
    56     # Wait for a small amount of time, in order for the killed process to release 
    57     # its control of the bound TCP port. 
    58     sleep 5; 
    59  
    60     $URL = HoneyClient::Agent->init(); 
    61  
    62     # Recreate a new stub handle, in case the global configuration has 
    63     # changed. 
    64     $stub = getClientHandle(address   => 'localhost', 
    65                             namespace => 'HoneyClient::Agent', 
    66                             fault_handler => \&_watchdogFaultHandler); 
    67  
    68     # Restore state information. 
    69     if (defined($agentState)) { 
    70         $som = $stub->updateState(encode_base64(nfreeze($agentState))); 
    71     } 
    72 
    73  
    74 $stub = getClientHandle(address   => 'localhost', 
    75                         namespace => 'HoneyClient::Agent', 
    76                         fault_handler => \&_watchdogFaultHandler); 
    77                  
    78 for (;;) { 
    79     # TODO: Make this a programmatic value. 
    80     sleep (5); 
    81     $som = $stub->getState(); 
    82     if (defined($som) and (ref($som) eq "SOAP::SOM")) { 
    83         $tempState = $som->result(); 
    84         if (defined($tempState)) { 
    85             # Make sure the new state is parsable, before saving it. 
    86             eval { 
    87                 $tempState = thaw(decode_base64($tempState)); 
    88             }; 
    89             if (!$@) { 
    90                 $agentState = $tempState; 
    91             } 
    92         } 
    93     } 
    94 
    95  
    96 HoneyClient::Agent->destroy(); 
     25#HoneyClient::Agent->destroy();