Пример #1
0
static int app_send_command_on_condition(struct stasis_app_control *control,
					 stasis_app_command_cb command_fn, void *data,
					 command_data_destructor_fn data_destructor,
					 app_command_can_exec_cb can_exec_fn)
{
	RAII_VAR(struct stasis_app_command *, command, NULL, ao2_cleanup);

	if (control == NULL || control->is_done) {
		/* If exec_command_on_condition fails, it calls the data_destructor.
		 * In order to provide consistent behavior, we'll also call the data_destructor
		 * on this error path. This way, callers never have to call the
		 * data_destructor themselves.
		 */
		if (data_destructor) {
			data_destructor(data);
		}
		return -1;
	}

	command = exec_command_on_condition(
		control, command_fn, data, data_destructor, can_exec_fn);
	if (!command) {
		return -1;
	}

	return command_join(command);
}
Пример #2
0
static int app_send_command_on_condition(struct stasis_app_control *control,
        stasis_app_command_cb command_fn, void *data,
        app_command_can_exec_cb can_exec_fn)
{
    RAII_VAR(struct stasis_app_command *, command, NULL, ao2_cleanup);

    if (control == NULL) {
        return -1;
    }

    command = exec_command_on_condition(
                  control, command_fn, data, can_exec_fn);
    if (!command) {
        return -1;
    }

    return command_join(command);
}
Пример #3
0
static struct stasis_app_command *exec_command(
    struct stasis_app_control *control, stasis_app_command_cb command_fn,
    void *data)
{
    return exec_command_on_condition(control, command_fn, data, NULL);
}