diff options
author | Haru <haru@dotalux.com> | 2015-09-15 12:12:01 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-09-25 12:48:09 +0200 |
commit | e99bf73af31a8b1f09b9ce033c16832ee5cac51d (patch) | |
tree | a3fb96017847c3a38cbf837bf322296e849184f9 /src/common/HPM.c | |
parent | 8c2976608d48a1dd2b32ac0386604566910a3522 (diff) | |
download | hercules-e99bf73af31a8b1f09b9ce033c16832ee5cac51d.tar.gz hercules-e99bf73af31a8b1f09b9ce033c16832ee5cac51d.tar.bz2 hercules-e99bf73af31a8b1f09b9ce033c16832ee5cac51d.tar.xz hercules-e99bf73af31a8b1f09b9ce033c16832ee5cac51d.zip |
Corrected a plugin unload issue
- This doesn't affect the current unloading function (executed at
shutdown), but it is only related to the (upcoming) manual plugin
unloading.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/HPM.c')
-rw-r--r-- | src/common/HPM.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c index 2277b9c71..23265fa24 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -477,31 +477,32 @@ struct hplugin *hplugin_load(const char* filename) { return plugin; } -void hplugin_unload(struct hplugin* plugin) { - unsigned int i = plugin->idx; - - if( plugin->filename ) +void hplugin_unload(struct hplugin* plugin) +{ + if (plugin->filename) aFree(plugin->filename); - if( plugin->dll ) + if (plugin->dll) plugin_close(plugin->dll); /* TODO: for manual packet unload */ /* - Go through known packets and unlink any belonging to the plugin being removed */ - aFree(plugin); if (!HPM->off) { - int cursor = 0; - HPM->plugins[i] = NULL; - for(i = 0; i < HPM->plugin_count; i++) { - if( HPM->plugins[i] == NULL ) + int i, cursor; + for (cursor = 0; cursor < HPM->plugin_count; cursor++) { + if (HPM->plugins[cursor]->idx != plugin->idx) continue; - if( cursor != i ) - HPM->plugins[cursor] = HPM->plugins[i]; + HPM->plugins[cursor] = NULL; + break; + } + for(i = cursor + 1; i < HPM->plugin_count; i++) { + HPM->plugins[cursor] = HPM->plugins[i]; cursor++; } - if( !(HPM->plugin_count = cursor) ) { + if (!(HPM->plugin_count = cursor)) { aFree(HPM->plugins); HPM->plugins = NULL; } } + aFree(plugin); } /** |