Fix bug #180 - Crash after signal SIGHUP.
This commit is contained in:
parent
a9b5c6db38
commit
8607b40278
@ -20,7 +20,8 @@
|
|||||||
#include "uhub.h"
|
#include "uhub.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define CRASH_DEBUG
|
// #define CRASH_DEBUG
|
||||||
|
// #define DEBUG_UNLOAD_PLUGINS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_HELP_MSG 16384
|
#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..."));
|
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)
|
static int command_shutdown_hub(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
|
||||||
{
|
{
|
||||||
cbase->hub->status = hub_status_shutdown;
|
cbase->hub->status = hub_status_shutdown;
|
||||||
@ -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("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("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" );
|
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)
|
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->origin = cmdh->origin;
|
||||||
command->handler = plugin_command_dispatch;
|
command->handler = plugin_command_dispatch;
|
||||||
|
|
||||||
cmdh->internal_handle = data;
|
cmdh->internal_handle = command;
|
||||||
list_append(data->commands, cmdh);
|
list_append(data->commands, cmdh);
|
||||||
command_add(plugin_get_hub(plugin)->commands, command, (void*) plugin);
|
command_add(plugin_get_hub(plugin)->commands, command, (void*) plugin);
|
||||||
|
printf("*** Add plugin command: %s (%p, %p)\n", command->prefix, command, cmdh);
|
||||||
return 0;
|
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 plugin_callback_data* data = get_callback_data(plugin);
|
||||||
struct command_handle* command = (struct command_handle*) cmdh->internal_handle;
|
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);
|
list_remove(data->commands, cmdh);
|
||||||
cmdh->internal_handle = 0;
|
command_del(plugin_get_hub(plugin)->commands, command);
|
||||||
|
hub_free(command);
|
||||||
command_del(plugin_get_hub(plugin)->commands, (void*) command);
|
cmdh->internal_handle = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ void plugin_close(struct uhub_plugin* plugin)
|
|||||||
LOG_PLUGIN("plugin_close: \"%s\"", plugin->filename);
|
LOG_PLUGIN("plugin_close: \"%s\"", plugin->filename);
|
||||||
plugin_callback_data_destroy(internals->callback_data);
|
plugin_callback_data_destroy(internals->callback_data);
|
||||||
hub_free(internals);
|
hub_free(internals);
|
||||||
|
plugin->internals = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_DLOPEN
|
#ifdef HAVE_DLOPEN
|
||||||
dlclose(plugin->handle);
|
dlclose(plugin->handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user