Changeset 253 for Evidence/Evidence.cc


Ignore:
Timestamp:
07/20/10 12:34:13 (14 years ago)
Author:
ogrimm
Message:
Added command ResetAlarm, Evidence servers now always safely translate a DIM string into a C string, added documentation, replaced several vectors my maps
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Evidence/Evidence.cc

    r232 r253  
    134134//////////////////////////
    135135
     136// Initialise
    136137int EvidenceServer::ConfigSignal = 0;
    137138EvidenceServer *EvidenceServer::This = NULL;
    138139
    139 // Constructor starts server with given name
    140 EvidenceServer::EvidenceServer(const char *ServerName): Name(ServerName) {
     140// Constructor
     141EvidenceServer::EvidenceServer(string ServerName): Name(ServerName) {
    141142
    142143  // Initialize
     
    176177
    177178  // Start server
    178   start(ServerName);
     179  start(ServerName.c_str());
    179180  addExitHandler(this);
    180181}
     
    184185
    185186  Message(INFO, "Server stopped");
    186  
     187
    187188  delete ConfClass;
    188   delete MessageService;
    189   delete[] MessageData;
    190  
     189
    191190  int Ret;
    192191  if ((Ret = pthread_mutex_destroy(&Mutex)) != 0) {
    193192        Message(ERROR, "pthread_mutex_destroy() failed (%s)", strerror(Ret));
    194193  }
     194 
     195  delete MessageService;
     196  delete[] MessageData; 
    195197}
    196198
     
    203205
    204206// DIM error handler
    205 void EvidenceServer::errorHandler(int Severity, int Code, char *Text) {   
     207void EvidenceServer::errorHandler(int Severity, int Code, char *Text) {
     208
    206209  Message(ERROR, "%s (DIM error code %d, DIM severity %d)\n", Text, Code, Severity);
    207210}
     
    233236  SendToLog("%s (%s): %s", MessageService->getName(), StateString[Severity], NewMsg->Text);
    234237
    235   // Update DIM message service, then delete old message
     238  // Update DIM message service
    236239  if (MessageService != NULL) {
    237240        MessageService->updateService(NewMsg, sizeof(struct Message)+strlen(NewMsg->Text)+1);
    238241  }
     242
     243  // Terminate if severity if FATAL 
     244  if (Severity == FATAL) exit(EXIT_FAILURE);
     245
     246  // Delete old message
     247  // Note that Lock()/Unlock() might fail with a FATAL message. To avoid an infinite loop,
     248  // check for FATAL severity is done before here.
     249  Lock();
    239250  delete[] MessageData;
    240251  MessageData = NewMsg;
    241 
    242   // Terminate if severity if FATAL 
    243   if (Severity == FATAL) exit(EXIT_FAILURE);
     252  Unlock(); 
    244253}
    245254
Note: See TracChangeset for help on using the changeset viewer.