Fix bug #180 - Crash after signal SIGHUP.
This commit is contained in:
parent
a9b5c6db38
commit
8607b40278
@ -20,7 +20,8 @@
|
||||
#include "uhub.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define CRASH_DEBUG
|
||||
// #define CRASH_DEBUG
|
||||
// #define DEBUG_UNLOAD_PLUGINS
|
||||
#endif
|
||||
|
||||
#define MAX_HELP_MSG 16384
|
||||
@ -584,6 +585,23 @@ static int command_reload(struct command_base* cbase, struct hub_user* user, str
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("Reloading configuration..."));
|
||||
}
|
||||
|
||||
#ifdef DEBUG_UNLOAD_PLUGINS
|
||||
int hub_plugins_load(struct hub_info* hub);
|
||||
int hub_plugins_unload(struct hub_info* hub);
|
||||
|
||||
static int command_load(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
hub_plugins_load(cbase->hub);
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("Loading plugins..."));
|
||||
}
|
||||
|
||||
static int command_unload(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
hub_plugins_unload(cbase->hub);
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("Unloading plugins..."));
|
||||
}
|
||||
#endif /* DEBUG_UNLOAD_PLUGINS */
|
||||
|
||||
static int command_shutdown_hub(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
cbase->hub->status = hub_status_shutdown;
|
||||
@ -918,7 +936,7 @@ void commands_builtin_add(struct command_base* cbase)
|
||||
ADD_COMMAND("register", 8, "p", auth_cred_guest, command_register, "Register your username." );
|
||||
ADD_COMMAND("reload", 6, "", auth_cred_admin, command_reload, "Reload configuration files." );
|
||||
ADD_COMMAND("password", 8, "p", auth_cred_user, command_password, "Change your own password." );
|
||||
ADD_COMMAND("shutdown", 8, "", auth_cred_admin, command_shutdown_hub, "Shutdown hub." );
|
||||
ADD_COMMAND("shutdown", 8, "", auth_cred_admin, command_shutdown_hub, "Shutdown hub." );
|
||||
ADD_COMMAND("stats", 5, "", auth_cred_super, command_stats, "Show hub statistics." );
|
||||
ADD_COMMAND("unban", 5, "n", auth_cred_operator, command_unban, "Lift ban on a user" );
|
||||
ADD_COMMAND("unmute", 6, "n", auth_cred_operator, command_mute, "Unmute user" );
|
||||
@ -930,6 +948,11 @@ void commands_builtin_add(struct command_base* cbase)
|
||||
ADD_COMMAND("userpass", 8, "np",auth_cred_operator, command_userpass, "Change password for a user." );
|
||||
ADD_COMMAND("version", 7, "", auth_cred_guest, command_version, "Show hub version info." );
|
||||
ADD_COMMAND("whoip", 5, "a", auth_cred_operator, command_whoip, "Show users matching IP range" );
|
||||
|
||||
#ifdef DEBUG_UNLOAD_PLUGINS
|
||||
ADD_COMMAND("load", 4, "", auth_cred_admin, command_load, "Load plugins." );
|
||||
ADD_COMMAND("unload", 6, "", auth_cred_admin, command_unload, "Unload plugins." );
|
||||
#endif /* DEBUG_UNLOAD_PLUGINS */
|
||||
}
|
||||
|
||||
void commands_builtin_remove(struct command_base* cbase)
|
||||
|
@ -127,9 +127,10 @@ static int cbfunc_command_add(struct plugin_handle* plugin, struct plugin_comman
|
||||
command->origin = cmdh->origin;
|
||||
command->handler = plugin_command_dispatch;
|
||||
|
||||
cmdh->internal_handle = data;
|
||||
cmdh->internal_handle = command;
|
||||
list_append(data->commands, cmdh);
|
||||
command_add(plugin_get_hub(plugin)->commands, command, (void*) plugin);
|
||||
printf("*** Add plugin command: %s (%p, %p)\n", command->prefix, command, cmdh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -138,11 +139,11 @@ static int cbfunc_command_del(struct plugin_handle* plugin, struct plugin_comman
|
||||
struct plugin_callback_data* data = get_callback_data(plugin);
|
||||
struct command_handle* command = (struct command_handle*) cmdh->internal_handle;
|
||||
|
||||
printf("*** Del plugin command: %s (%p, %p)\n", command->prefix, command, cmdh);
|
||||
list_remove(data->commands, cmdh);
|
||||
cmdh->internal_handle = 0;
|
||||
|
||||
command_del(plugin_get_hub(plugin)->commands, (void*) command);
|
||||
|
||||
command_del(plugin_get_hub(plugin)->commands, command);
|
||||
hub_free(command);
|
||||
cmdh->internal_handle = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@ void plugin_close(struct uhub_plugin* plugin)
|
||||
LOG_PLUGIN("plugin_close: \"%s\"", plugin->filename);
|
||||
plugin_callback_data_destroy(internals->callback_data);
|
||||
hub_free(internals);
|
||||
plugin->internals = NULL;
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
dlclose(plugin->handle);
|
||||
|
Loading…
Reference in New Issue
Block a user