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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.