Changeset 187 for Evidence


Ignore:
Timestamp:
03/29/10 09:28:17 (14 years ago)
Author:
ogrimm
Message:
Updates to signal handling
Location:
Evidence
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Evidence/Config.cc

    r171 r187  
    3636    DimService *ConfigModified;
    3737    int ModifyTime;
    38        
     38
    3939    void rpcHandler();
    4040 
     
    4545        void ConfigChanged();
    4646};
     47
    4748
    4849// Constructor
  • Evidence/Evidence.cc

    r178 r187  
    4747  signal(SIGINT, &SignalHandler);   // CTRL-C
    4848  signal(SIGHUP, &SignalHandler);   // Terminal closed
    49  
     49
    5050  // Catch C++ unhandled exceptions
    5151  set_terminate(Terminate);
     
    5757  string Rev(EVIDENCE_REVISION);
    5858  Rev = Rev.substr(1, Rev.size()-3);
    59   if (asprintf(&InitMsg, "Server started (%s, compiled %s %s)", Rev.c_str(),__DATE__, __TIME__) == -1) InitMsg = NULL;
     59  snprintf(InitMsg, sizeof(InitMsg), "Server started (%s, compiled %s %s)", Rev.c_str(),__DATE__, __TIME__);
    6060 
    6161  Status = new DimService((ServerName+"/Status").c_str(), (char *) "C", InitMsg, strlen(InitMsg)+1);
     
    6868EvidenceServer::~EvidenceServer() {
    6969
    70   free(InitMsg);
    7170  State(INFO, "Server stopped");
    7271 
     
    7978// DIM exit handler
    8079void EvidenceServer::exitHandler(int Code) {
     80
    8181  State(INFO, "Exit handler called (DIM exit code %d)", Code);
    8282  exit(EXIT_SUCCESS);
     
    181181
    182182// Signal handler (causes pause() and other syscalls to return)
    183 void EvidenceServer::SignalHandler(int) {
    184 
    185   ThisServer->ExitRequest = true;
     183void EvidenceServer::SignalHandler(int Signal) {
     184
     185  static bool Called = false;
     186
     187  if (!Called) {
     188        Called = true;
     189        ThisServer->ExitRequest = true;
     190        return;
     191  }
     192
     193  // If invoked twice, call exit()
     194  ThisServer->State(ThisServer->WARN, "Signal handler called again, invoking exit() (signal %d)", Signal);
     195  exit(EXIT_FAILURE);
    186196}
    187197
  • Evidence/Evidence.h

    r178 r187  
    2020class EvidenceServer: public DimServer {
    2121  private:
    22 
    2322        // This class will contain in LastModifyTime always
    2423        // the unix time of the last config file update
     
    5150        class ConfigUpdate *ModifyInfo;
    5251       
    53         char *InitMsg;
     52        char InitMsg[STATUS_SIZE];
    5453        int LastModifyTime;
    5554
  • Evidence/readme.txt

    r186 r187  
    55Config is the configuration server and needs to run before any other DIM
    66server that requests configuration information is started (if a configuration
    7 request cannot be answered, a server will normally not start). As default,
    8 it reads Evidence.conf in the config subdirectory. A different configuration
     7request cannot be answered, a server will normally not start). A configuration
    98file can be given on the command line.
    109
     
    1817
    1918The DIMDIR environment variable needs to point to the DIM installation directory
    20 when compiling. DIM_DNS_NODE must point to a name server for any DIM server
     19when compiling. DIM_DNS_NODE must point to the name server for any DIM server
    2120to run.
    2221
Note: See TracChangeset for help on using the changeset viewer.