Reputation: 165
I'm implementing a Linux application that supports live software upgrade (without process restart). To support this functionality I have broken my application into two parts
High level approach is to bring the application to a quiescent state, hold incoming messages in a message queue and the replace the old shared module (using dlopen) with the new implementation in the module proxy.
However, during upgrade phase I will have two instance of similar shared object, old module implementation and new module implementation dynamically loaded into module proxy at the same time. Is this possible? Will it cause symbol collision? What's the best way to achieve this state safely?
Upvotes: 0
Views: 298
Reputation: 213526
Dynamic shared module that can be unloaded and reloaded with the new implementation during program update.
In general this approach is fraught with peril. In particular, calling dlclose
may not actually unload the library when you expect. The rules for when a library can and can not be unloaded are subtle and not well documented.
You should try to dlopen()
, use the library, then dlclose()
it, and verify that it is actually unloaded (by examining /proc/$pid/maps
).
The "two processes" approach suggested by KamilCuk is going to be significantly more reliable.
I considered two process approach but moving messages between two processes might cause performance issue
yugr@ suggests using dlmopen()
, which might work. But it is even less documented and tested, and is also Linux-specific.
during upgrade phase I will have two instance of similar shared object
That is going to be even more problematic, but it's unclear why you can't dlclose()
the old version before dlopen()
ing the new one.
Upvotes: 1