mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-06-25 17:46:38 +02:00
d2ccba80c5
The LoadPersistent*()/SavePersistent*() functions caused moddata to be tagged with ->unloaded=1. Though it seems it caused no real issues this is not good... we now properly tag them as 0 and the like. Also did a code cleanup / overhaul on that system as well. For other ModData we now handle the case where a module is loaded with with a newer version and that newer version is no longer having certain moddata, eg the name changed or it no longer needs it. KNOWN ISSUE: Unfortunately we cannot call the free function for the old moddata that is no longer being handled by the newer version of the module, since the module is already unloaded. So this will result in a memory leak, but not in a crash. KNOWN ISSUE: Similarly, for SavePersistentPointer() there is a free function, again this is called just fine if the module is permanently unloaded but NOT if the module is reloaded with the same name and no longer is interested in the persistent pointer object. Again, here too, that would result in a memory leak but not in a crash. Fortunately the "known issues" are rare. Fixing these is impossible with the current module API because modules are unloaded after MOD_TEST and before MOD_INIT, and only after MOD_INIT we know which moddata is handled by the new version of the module. To change that we would need to keep the old module around until after MOD_INIT of the new module (so we can call free functions in the old module), but that means delaying the MOD_UNLOAD for the old modules until after MOD_INIT of the new modules, which changes the sequence too much that i don't dare to do that. For example, it would mean a database save routine in the old module would only be called after MOD_INIT finished in the new module, which may be unexpected since right now MOD_UNLOAD is called before MOD_INIT and maybe the db loading is done in MOD_INIT, which would need to be moved to MOD_LOAD. That's just one example, there may be others. I think such a change can only be done on a major UnrealIRCd version change, so we will have to live this for now. As said, fortunately it is a corner case.