httpd: better handling of first-time notifications
ensure new listeners get notified on first update loop also cleanup the PropertyChangeObserver on reset
This commit is contained in:
parent
a42516bcdd
commit
1867ccb4a8
3 changed files with 13 additions and 2 deletions
|
@ -46,8 +46,12 @@ void PropertyChangeObserver::check()
|
|||
continue;
|
||||
}
|
||||
|
||||
(*it)->_changed = (*it)->_prevValue != (*it)->_node->getStringValue();
|
||||
if ((*it)->_changed) (*it)->_prevValue = (*it)->_node->getStringValue();
|
||||
if( false == (*it)->_changed ) {
|
||||
(*it)->_changed = (*it)->_prevValue != (*it)->_node->getStringValue();
|
||||
if ((*it)->_changed)
|
||||
(*it)->_prevValue = (*it)->_node->getStringValue();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +66,10 @@ const SGPropertyNode_ptr PropertyChangeObserver::addObservation( const string pr
|
|||
{
|
||||
for (Entries_t::iterator it = _entries.begin(); it != _entries.end(); ++it) {
|
||||
if (propertyName == (*it)->_node->getPath(true) ) {
|
||||
// if a new observer is added to a property, mark it as changed to ensure the observer
|
||||
// gets notified on initial call. This also causes a notification for all other observers of this
|
||||
// property.
|
||||
(*it)->_changed = true;
|
||||
return (*it)->_node;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
void check();
|
||||
void uncheck();
|
||||
|
||||
void clear() { _entries.clear(); }
|
||||
|
||||
private:
|
||||
typedef std::vector<PropertyChangeObserverEntryRef> Entries_t;
|
||||
Entries_t _entries;
|
||||
|
|
|
@ -161,6 +161,7 @@ void MongooseHttpd::unbind()
|
|||
{
|
||||
mg_destroy_server(&_server);
|
||||
_uriHandlers.clear();
|
||||
_propertyChangeObserver.clear();
|
||||
}
|
||||
|
||||
void MongooseHttpd::shutdown()
|
||||
|
|
Loading…
Add table
Reference in a new issue