Changeset 381
- Timestamp:
- 05/25/07 19:14:14 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
honeyclient/branches/exp/kindlund-filesystem/lib/HoneyClient/Agent.pm
r378 r381 196 196 # TODO: Include corresponding unit tests. 197 197 # XXX: Check if this is still needed. 198 #use HoneyClient::Agent::Integrity;198 use HoneyClient::Agent::Integrity; 199 199 200 200 # Include Thread Libraries … … 377 377 # XXX: Disabled temporarily. 378 378 if ($PERFORM_INTEGRITY_CHECKS) { 379 require HoneyClient::Agent::Integrity;379 # require HoneyClient::Agent::Integrity; 380 380 $gintegrity = HoneyClient::Agent::Integrity->new(); 381 381 $gintegrity->closeFiles(); … … 708 708 print "Creating a new run() child thread...\n"; 709 709 } 710 711 # XXX: If the old thread is dead, we could potentially712 # join it, in order to avoid detach warnings upon exit.713 710 714 711 # Quickly define a temporary thread ID. … … 729 726 _unlock($data); 730 727 731 $thread = threads->create(\& childThread,728 $thread = threads->create(\&worker, 732 729 { 733 730 'driver_name' => $driverName, … … 744 741 # XXX: Debugging, remove eventually. 745 742 print "Thread ID = " . $thread->tid() . "\n"; 746 #$data->{$driverName}->{'thread_id'} = $thread->tid();747 743 } else { 748 744 # XXX: Debugging, remove eventually. 749 745 print "Thread ID = " . $thread->tid() . " (NOT RUNNING)\n"; 750 #print "Thread ID = undef\n";751 #$data->{$driverName}->{'thread_id'} = undef;752 746 } 753 747 754 748 # Release data lock. 755 749 _unlock($data); 756 757 # XXX: Check to see if this works okay.758 # $thread->join();759 750 } 760 751 … … 783 774 # to properly deal with exceptions/faults that occur within this 784 775 # thread. 785 sub childThread{776 sub worker { 786 777 787 778 # Extract arguments. … … 789 780 790 781 my $driverName = $args->{'driver_name'}; 791 my $integrity = $args->{'integrity'};782 my $integrity = $args->{'integrity'}; 792 783 793 784 # Temporary variable, used to hold thawed driver data. … … 795 786 796 787 # XXX: Check if we need this. 797 #threads->yield();788 threads->yield(); 798 789 799 790 # Trap all faults that may occur from these asynchronous operations. … … 813 804 $data = _lock(); 814 805 815 #if ($PERFORM_INTEGRITY_CHECKS) {816 # require HoneyClient::Agent::Integrity;817 # # XXX: WARNING - The $integrityState object data is NOT thread-safe818 # # (since it relies on external data stored on the file system).819 # # As such, do NOT try to call integrity checks on multiple, simultaneous820 # # asynchronous threaded drivers.821 # #$integrity = thaw($integrityState);822 # # Perform initial integrity baseline check.823 # #print "Initializing Integrity Check...\n";824 # # TODO: Initialize Integrity Checks825 # $integrity = HoneyClient::Agent::Integrity->new();826 #}827 828 806 # Now, initialize each driver object. 829 807 # Figure out which $driver object to use... 830 808 my $driverClass = 'HoneyClient::Agent::Driver::Browser::' . $driverName; 831 # XXX: See if this is still needed.832 # eval "require $driverClass";833 # if ($@) {834 # Carp::croak "$@";835 # }836 809 837 810 if (!defined($data->{$driverName}->{'state'})) { … … 864 837 $data->{$driverName}->{'status'}->{'is_running'} = 1; 865 838 $data->{$driverName}->{'state'} = $driver; 866 867 # XXX: Check to see if this is okay.868 # if ($driver->isFinished()) {869 # # Thread is about to finish, set the ID back to undef.870 # # This looks ugly, but setting it this early avoids the871 # # potential race condition of when the run() thread is finished872 # # and when updateState() checks for $driverData->{$driverName}->{'thread_id'}873 # # to be set to undef.874 # $data->{$driverName}->{'thread_id'} = undef;875 # }876 839 877 840 # Release lock on stored driver state. … … 960 923 $data->{$driverName}->{'state'} = $driver; 961 924 962 # Thread is about to finish, set the ID back to undef.963 # XXX: Check to see if this is okay.964 # $data->{$driverName}->{'thread_id'} = undef;965 966 925 # Release lock on stored driver state. 967 926 _unlock($data); … … 969 928 # XXX: Debugging, remove eventually. 970 929 print "Exiting run() thread.\n"; 971 #print Dumper($driver);972 # Verbose debugging:973 #print Dumper($driver->status());974 # Short-hand debugging:975 #my $status = $driver->status();976 #print "R(" . $status->{relative_links_remaining} . ") | [ " .977 # "V(" . $status->{links_remaining} . ") + ".978 # "P(" . $status->{links_processed} . ") = " .979 # "T(" . $status->{links_total} . ") ] " .980 # "| (" . $status->{percent_complete} . ")\n";981 930 }; 982 931 … … 992 941 _unlock(); 993 942 994 # Acquire lock on stored driver state.995 $data = _lock();996 997 # Make sure we update our state to reflect ourself dying.998 # XXX: Check to see if this is okay.999 # $data->{$driverName}->{'thread_id'} = undef;1000 1001 # Release lock on stored driver state.1002 _unlock($data);1003 1004 943 # TODO: Do proper fault queuing. 1005 944 print "FAULT: " . $@ . "\n";
