Hi all,
The issue is on github
link
Then we continue the discuss.
But I don't understand the "implicit" dependence you mention... It seems you mean that for some reason your application wants to know when or whether B is loaded
Actually, I'm talking about the reference count of A, and B depends on A. When load B, it will recursive dlopen A.
So, there is a question, when load B how could OSv add A's reference count too?
If we don't know the count, when unload A and load A again, because A is still in memory, dlopen A will return a handle. the static variables in A will not be reinitialized. If we use
static variables's default constructors dynamic create some thing in dlopen(we know that dlopen will do init first and then transfer control to main), if A is in already in memory the init will not work!
The following is the whole process:
1. load A
2. load B(B
depends on A
)
3. unload A
4. load A ----->
static variables in A will not be reinitialized
If we have reference count of A is still 1(because we implement reference count ourselves, I think when we unload A the reference count is 0, but dlopen in system will be 1), then we know A is still in memory, and do some work do deal with it.
Of course, we can also judge whether A is already in memory use dlopen with RTLD_NOLOAD , if A is in memory we will deal with it.