Locking up on startup
-
In another post majkp reported a compatibility problem with FLHook-plugin 1.6.0 and these plugins
- givecash 0.5
- bounty 0.2
These work fine with 1.5.9 but on a single machine (unfortunately the main FL server) they cause hook to lock up on startup. I can’t replicate this fault on other machines - it works fine with both 1.6.0 and 1.5.9!
The symptom of the fault is that FLserver shows the “…LOADING…” message, server load remains at 33ms and after 10seconds to 4’ish minutes both flserver window and flhook windows dissapear (i.e. application crashs). The hook windows shows all of the plugin loaded messages but the admin port listening messages are not displayed and the hook console will not respond to commands. There are no errors in the log files - it just doesn’t work.
If these plugins are disabled on startup and manually loaded after startup, FLserver/hook works normally.
The problem seems to happen when LoadSettings() is called from hook. If I comment out the ;hook = LoadSettings,0 line from the plugin ini the problem goes away. Normally, on hook startup LoadSettings() is called twice, first on the dll load and second time from the LoadSettings() function in hook. I think this is okay.
Here’s an extract from the givecash plugin…
EXPORT void LoadSettings() { returncode = DEFAULT_RETURNCODE; iMinTransfer = IniGetI(set_scCfgFile, "GiveCash", "MinTransfer", 1); ...blah...blah... AddLog("Givecash: MinTransfer=%d CheatDetection=%d BlockedSystem=%s", iMinTransfer, bCheatDetection, scBlockedSystem.c_str()); } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { if(fdwReason == DLL_PROCESS_ATTACH) LoadSettings(); return true; }
If I comment out the AddLog line, hook will load the plugin on startup properly. I’ve inspected plugin code for this function and the hook code called by it and I can’t see any problems. What am I doing wrong?
This feels like a threading issue…I notice that:
-The Update() hook calls FLHookInit() which calls LoadSettings()
-The plugins are loaded (on startup from) Startup() hook which calls FLHookInit_Pre() which calls PluginManager::LoadPlugins().
-FLHookInit_Pre() opens the log file and LoadSettings in the plugin uses it.
-Are the Update() and Startup() hook callbacks in different threads?
-I see that FLHookInit_Pre uses InitializeCriticalSection.This isn’t a critical problem for me; I can just remove any AddLog function calls from LoadSettings but I would really like to understand the underlying problem.