Changeset ad39c2


Ignore:
Timestamp:
Jul 6, 2012, 10:18:44 AM (13 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
865a218
Parents:
2a20bd
git-author:
Frederik Heber <heber@…> (06/01/12 17:46:15)
git-committer:
Frederik Heber <heber@…> (07/06/12 10:18:44)
Message:

Server now uses SignalHandler as well (as poolworker does).

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Makefile.am

    r2a20bd rad39c2  
    413413  ${CodePatterns_LIBS}
    414414
    415 Server_SOURCES = $(SERVERSOURCE) $(SERVERHEADER) Server.cpp DefaultOptions.cpp DefaultOptions.hpp SignalOptions.cpp SignalOptions.hpp ServerOptions.cpp ServerOptions.hpp
     415Server_SOURCES = $(SERVERSOURCE) $(SERVERHEADER) Server.cpp DefaultOptions.cpp DefaultOptions.hpp SignalHandler.cpp SignalHandler.hpp SignalOptions.cpp SignalOptions.hpp ServerOptions.cpp ServerOptions.hpp
    416416Server_LDFLAGS = $(AM_LDFLAGS) $(BOOST_PROGRAM__OPTIONS_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS)
    417417Server_CXXFLAGS = $(AM_CPPFLAGS)
  • src/Server.cpp

    r2a20bd rad39c2  
    2626#include "CodePatterns/MemDebug.hpp"
    2727
    28 #include <boost/lexical_cast.hpp>
    2928#include <boost/program_options.hpp>
    3029#include <iostream>
    31 #include <signal.h>
    3230
    3331#include "Fragmentation/Automation/atexit.hpp"
     
    3836#include "Jobs/SystemCommandJob.hpp"
    3937#include "ServerOptions.hpp"
     38#include "SignalHandler.hpp"
    4039
    41 
    42 //!> global shutdown function
    43 boost::function<void (int)> shutdownfunction;
    44 //!> global signal vector for later releasing
    45 std::vector<size_t> signals;
    46 //!> counter for the number of received signals
    47 size_t NoSignalsReceived = 0;
    48 //!> maximum number of received signals after which the handlers are released
    49 const size_t MAX_NOSIGNALSRECEIVED = 3;
    50 
    51 void signalhandler(int sig)
    52 {
    53   // increment received signal counter
    54   ++NoSignalsReceived;
    55 
    56   // shutdown if we have handler
    57   if (shutdownfunction)
    58     shutdownfunction(sig);
    59 
    60   if (NoSignalsReceived >= MAX_NOSIGNALSRECEIVED) {
    61     // release signal hook again
    62     for (std::vector<size_t>::const_iterator iter = signals.begin();
    63         iter != signals.end(); ++iter)
    64       signal(*iter, NULL);
    65   }
    66 }
    6740
    6841int main(int argc, char* argv[])
     
    10780
    10881    // catch ctrl-c and shutdown worker properly
    109     shutdownfunction = boost::bind(&FragmentScheduler::shutdown, boost::ref(Server), _1);
    110     if (vm.count("signal")) {
    111       signals =  vm["signal"].as< std::vector<size_t> >();
    112       for (std::vector<size_t>::const_iterator iter = signals.begin();
    113           iter != signals.end(); ++iter) {
    114         LOG(0, "STATUS: Catching signal " << *iter << " via signal handler.");
    115         signal(*iter, &signalhandler);
    116       }
    117     } else {
    118       LOG(0, "STATUS: No signals are caught.");
    119     }
     82    boost::function<void (int)> shutdownfunction = boost::bind(&FragmentScheduler::shutdown, boost::ref(Server), _1);
     83    SignalHandler signalhandler(shutdownfunction, ServerOpts.signals);
    12084
    12185    {
Note: See TracChangeset for help on using the changeset viewer.