Exemplo n.º 1
0
void ast_ari_asterisk_unload_module(struct ast_variable *headers,
	struct ast_ari_asterisk_unload_module_args *args,
	struct ast_ari_response *response)
{
	int unload_result;
	enum ast_module_unload_mode unload_mode = AST_FORCE_SOFT;

	ast_assert(response != NULL);

	if (!ast_module_check(args->module_name)) {
		ast_ari_response_error(
			response, 404, "Not Found",
			"Module not found in running modules");
		return;
	}

	unload_result = ast_unload_resource(args->module_name, unload_mode);

	if (unload_result != 0) {
		ast_ari_response_error(
			response, 409, "Conflict",
			"Module could not be unloaded");
		return;
	}

	ast_ari_response_no_content(response);
}
Exemplo n.º 2
0
static int handle_unload(int fd, int argc, char *argv[])
{
	int x;
	int force=AST_FORCE_SOFT;
	if (argc < 2)
		return RESULT_SHOWUSAGE;
	for (x=1;x<argc;x++) {
		if (argv[x][0] == '-') {
			switch(argv[x][1]) {
			case 'f':
				force = AST_FORCE_FIRM;
				break;
			case 'h':
				force = AST_FORCE_HARD;
				break;
			default:
				return RESULT_SHOWUSAGE;
			}
		} else if (x !=  argc - 1) 
			return RESULT_SHOWUSAGE;
		else if (ast_unload_resource(argv[x], force)) {
			ast_cli(fd, "Unable to unload resource %s\n", argv[x]);
			return RESULT_FAILURE;
		}
	}
	return RESULT_SUCCESS;
}
static void exit_now(GtkWidget *widget, gpointer data)
{
	ast_loader_unregister(mod_update);
	gtk_main_quit();
	inuse--;
	ast_update_use_count();
	ast_unregister_verbose(verboser);
	ast_unload_resource("pbx_gtkconsole", 0);
	if (option_verbose > 1)
		ast_verbose(VERBOSE_PREFIX_2 "GTK Console Monitor Exiting\n");
	/* XXX Trying to quit after calling this makes asterisk segfault XXX */
}
static void remove_module(void)
{
	int res;
	char *module;
	char buf[256];
	if (GTK_CLIST(modules)->selection) {
		module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
		gdk_threads_leave();
		res = ast_unload_resource(module, 0);
		gdk_threads_enter();
		if (res) {
			snprintf(buf, sizeof(buf), "Module '%s' is in use", module);
			update_statusbar(buf);
		} else {
			snprintf(buf, sizeof(buf), "Module '%s' removed", module);
			update_statusbar(buf);
		}
	}
}
static void reload_module(void)
{
	int res, x;
	char *module;
	char buf[256];
	if (GTK_CLIST(modules)->selection) {
		module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
		module = strdup(module);
		if (module) {
			gdk_threads_leave();
			res = ast_unload_resource(module, 0);
			gdk_threads_enter();
			if (res) {
				snprintf(buf, sizeof(buf), "Module '%s' is in use", module);
				update_statusbar(buf);
			} else {
				gdk_threads_leave();
				res = ast_load_resource(module);
				gdk_threads_enter();
				if (res) {
					snprintf(buf, sizeof(buf), "Error reloading module '%s'", module);
				} else {
					snprintf(buf, sizeof(buf), "Module '%s' reloaded", module);
				}
				for (x=0; x < GTK_CLIST(modules)->rows; x++) {
					if (!strcmp((char *)gtk_clist_get_row_data(GTK_CLIST(modules), x), module)) {
						gtk_clist_select_row(GTK_CLIST(modules), x, -1);
						break;
					}
				}
				update_statusbar(buf);
				
			}
			free(module);
		}
	}
}