Changeset 262 for Evidence/Bridge.cc


Ignore:
Timestamp:
07/26/10 17:53:31 (14 years ago)
Author:
ogrimm
Message:
Removed signaling to invoke ConfigChanged(), now it is run as separate thread. New command '/ResetMessage'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Evidence/Bridge.cc

    r253 r262  
    5050
    5151  public:
    52     Bridge(char *, int);
     52    Bridge();
    5353    ~Bridge();
    5454};
    5555
    56 // Constructor
    57 Bridge::Bridge(char *Name, int Port): EvidenceServer(SERVER_NAME) {
    58 
    59   // Set primary DIM network to subscribe from
    60   DimClient::setDnsNode(Name, Port);
    61 
    62   // Initialise and request notification of configuration changes
     56// Constructor (ConfigChanged() is automatically called at start-up)
     57Bridge::Bridge(): EvidenceServer(SERVER_NAME) {
     58
     59  // Initialise
    6360  ServerList = NULL;
    6461  GetConfig("cmdallow", " ");
    65   ActivateSignal(SIGUSR2);
    66  
    67   ConfigChanged();
    6862}
    6963
     
    9286
    9387  // Check if configuratiomn changed
    94   if (ExcludeString == GetConfig("exclude")) return;
    95   ExcludeString = GetConfig("exclude");
    96  
    97   // Remove all previous subscriptions
    98   Undo();
    99 
     88  string NewExcludeString = GetConfig("exclude");
     89
     90  Lock();
     91  if (ExcludeString != NewExcludeString) ExcludeString.swap(NewExcludeString);
     92  Unlock();
     93  if (ExcludeString == NewExcludeString) return;
     94   
    10095  // Compile regular expressions
    10196  regex_t R;
     97  vector<regex_t> RegEx;
     98
    10299  vector<string> Exclude = Tokenize(ExcludeString, " \t");
    103100  for (int i=0; i<Exclude.size(); i++) {
     
    111108  }
    112109
    113   // Subscribe to top-level server list
     110  // Remove previous data, set new regular expressions and subscribe to top-level server list
     111  Lock();
     112  Undo();
     113  Bridge::RegEx = RegEx;
    114114  ServerList = new DimInfo((char *) "DIS_DNS/SERVER_LIST", NO_LINK, this);
     115  Unlock();
    115116}
    116117
     
    267268        exit(EXIT_FAILURE);
    268269  }
    269          
     270
     271  // Set primary DIM network to subscribe from
     272  DimClient::setDnsNode(argv[1], argc>2 ? atoi(argv[2]) : DEFAULT_PORT);
     273
    270274  // Static ensures calling of destructor by exit()
    271   static Bridge Class(argv[1], argc>2 ? atoi(argv[2]) : DEFAULT_PORT);
     275  static Bridge Class;
    272276 
    273277  // Sleep until signal caught
Note: See TracChangeset for help on using the changeset viewer.