Hi all!
I am developping an Observer Pattern that works between processes. In my library I am using a stl::map of observers. In fact, the map if index by a key and returns a STL list of observersIDs.
so it looks like:
map< const int, list < controlId > > ObserversMap;
In my Subject Class I have a thread that receives messages from other processes that want to attach to my Subject. The operations of attaching, updating/informing, detaching works fine.
The problem I see is when I try to put some robustness. I simulate a crash by killing my Subject via the kill(pid) command and then restart my Subject. Other processes are notified by a third process which manage all my processes. So the observers resend attach commands to the restarted Subject. Upon reception of those messages I get an observer already attached message!!! My list of Observers is still intact in memory even after my process was killed and restarted! Any idea of what could be happening? How can I stop this behavior. Closing cleanly is not a solution since I need to process the case where my process dies for any reason without having time to do a gentle close with memory deallocation. I thought that memory was cleaned has soon as the pid died.
Thanks for your help.
Frank
I am developping an Observer Pattern that works between processes. In my library I am using a stl::map of observers. In fact, the map if index by a key and returns a STL list of observersIDs.
so it looks like:
map< const int, list < controlId > > ObserversMap;
In my Subject Class I have a thread that receives messages from other processes that want to attach to my Subject. The operations of attaching, updating/informing, detaching works fine.
The problem I see is when I try to put some robustness. I simulate a crash by killing my Subject via the kill(pid) command and then restart my Subject. Other processes are notified by a third process which manage all my processes. So the observers resend attach commands to the restarted Subject. Upon reception of those messages I get an observer already attached message!!! My list of Observers is still intact in memory even after my process was killed and restarted! Any idea of what could be happening? How can I stop this behavior. Closing cleanly is not a solution since I need to process the case where my process dies for any reason without having time to do a gentle close with memory deallocation. I thought that memory was cleaned has soon as the pid died.
Thanks for your help.
Frank