Changeset 17915 for fact


Ignore:
Timestamp:
07/18/14 10:08:12 (10 years ago)
Author:
ogrimm
Message:
Removed erroneous static declaration in History.cc that made a variable grow in size indefinitely. The data collector has new a service indicating its subscriptions (as the history server)
Location:
fact/Evidence
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fact/Evidence/DColl.cc

    r12910 r17915  
    4545        float DataSizeMB, LogSizeMB;
    4646        int DataSizeLastUpdate, LogSizeLastUpdate;
    47     DimService *LogSizeService, *DataSizeService, *DataFilename;
     47    DimService *LogSizeService, *DataSizeService, *DataFilename, *SubscriptionService;
     48
    4849        int TimeForNextFile;
    4950
     
    113114  LogCommand = new DimCommand("DColl/Log", (char *) "C", this);
    114115
    115   // Subsribe to top-level server list (not via AddService() due to thread issue)
     116  // Create services for information about subscribed services
     117  SubscriptionService = new DimService(SERVER_NAME "/Subscriptions", "C", NULL, 0);
     118
     119  // Subscribe to top-level server list (not via AddService() due to thread issue)
    116120  ServerList = new DimInfo((char *) "DIS_DNS/SERVER_LIST", NO_LINK, this);
    117121}
     
    132136  delete LogSizeService;
    133137  delete DataSizeService;
     138  delete SubscriptionService;
    134139
    135140  // Close files
     
    151156// no mutex is needed to serialize writing to the file
    152157void DataHandler::infoHandler() {
     158
     159  static string SubscriptionList;
    153160
    154161  // Check if service available
     
    192199          Name = strtok(NULL, "|");
    193200        }
     201       
     202        // Update service subscription list
     203        stringstream Stream;
     204       
     205        for (unsigned int i=0; i<List.size(); i++) Stream << List[i].DataItem->getName() << '|';
     206
     207        SubscriptionList = Stream.str();
     208        SubscriptionService->updateService((void *) SubscriptionList.c_str(), SubscriptionList.size()+1); // Note that Subscription is a static variable
     209
    194210        return;
    195211  }
  • fact/Evidence/History.cc

    r17017 r17915  
    2929using namespace std;
    3030
    31 const int MIN_SIZE_KB = 50;                                     // Min and max buffersize in kByte (> 3*sizeof(int) !)
    32 const string DEFAULT_MAX_SIZE_KB = "2000";
    33 const string DEFAULT_NUM_ENTRIES = "1000";              // Number of entries in each history buffer
    34 const double MIN_SAVE_PERDIOD = 0.5;                    // Minimum period between saving history buffers in hours
    35 
    3631//
    3732// Class declaration
     
    3934class History:  public DimRpc, public DimClient, public EvidenceServer {
    4035
     36        static const int MIN_SIZE_KB = 50;                                      // Min and max buffersize in kByte (> 3*sizeof(int) !)
     37        static const string DEFAULT_MAX_SIZE_KB;
     38        static const string DEFAULT_NUM_ENTRIES;                                // Number of entries in each history buffer
     39 
    4140        struct Item {
    4241          DimStampedInfo *DataItem;
     
    5251       
    5352        DimInfo *ServerList;
    54         DimService *Service;
     53        DimService *SubscriptionService;
    5554        char *Directory;
    5655
     
    6867};
    6968
     69// Initialize non-integral constants (cannot be inside class declaration)
     70const string History::DEFAULT_MAX_SIZE_KB = "2000";
     71const string History::DEFAULT_NUM_ENTRIES = "1000";
     72static const double MIN_SAVE_PERIOD = 0.5;                      // Minimum period between saving history buffers in hours
     73
    7074
    7175// Constructor
     
    7377                                                         EvidenceServer(SERVER_NAME),
    7478                                                         Directory(Dir) {
     79
    7580  // Get/initialize configuration
    7681  GetConfig("minchange", " ");
     
    8186
    8287  // Create services for information about subscribed services
    83   Service = new DimService(SERVER_NAME "/Subscriptions", "C", NULL, 0);
     88  SubscriptionService = new DimService(SERVER_NAME "/Subscriptions", "C", NULL, 0);
    8489
    8590  // Subscribe to top-level server list
     
    9499  while (Map.size() != 0) RemoveService((*Map.begin()).first);
    95100 
    96   delete Service;
     101  delete SubscriptionService;
    97102}
    98103
     
    147152       
    148153        // Update service subscription list
    149         static stringstream Stream;
     154        stringstream Stream;
    150155       
    151156        for (map<string, struct Item>::const_iterator i=Map.begin(); i!=Map.end(); i++) {
     
    153158        }
    154159        List = Stream.str();
    155         Service->updateService((void *) List.c_str(), List.size()+1);
     160        SubscriptionService->updateService((void *) List.c_str(), List.size()+1); // Note that List is a static variable
    156161       
    157162        return;
     
    166171
    167172  // Save history buffers periodically (in case of program crash)
    168   if (time(NULL)-Map[Service].LastSave > max(atof(GetConfig("saveperiod").c_str()),MIN_SAVE_PERDIOD)*3600) {
     173  if (time(NULL)-Map[Service].LastSave > max(atof(GetConfig("saveperiod").c_str()), MIN_SAVE_PERIOD)*3600) {
    169174    Map[Service].LastSave = time(NULL);
    170175        SaveHistory(Service);
Note: See TracChangeset for help on using the changeset viewer.