Skip to content

Commit

Permalink
rename module_call and modcall to just module
Browse files Browse the repository at this point in the history
There's no "module" keyword, but it's clear what the intent is.
Any reference to a module is when we *call* a module.
  • Loading branch information
alandekok committed Apr 3, 2018
1 parent 8deb2a7 commit 07de411
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 57 deletions.
20 changes: 10 additions & 10 deletions src/unlang/compile.c
Expand Up @@ -96,11 +96,11 @@ static void dump_mc(unlang_t *c, int indent)
{
int i;

if(c->type==UNLANG_TYPE_MODULE_CALL) {
unlang_module_call_t *single = unlang_generic_to_module_call(c);
if(c->type==UNLANG_TYPE_MODULE) {
unlang_module_t *single = unlang_generic_to_module(c);
DEBUG("%.*s%s {", indent, "\t\t\t\t\t\t\t\t\t\t\t",
single->module_instance->name);
} else if ((c->type > UNLANG_TYPE_MODULE_CALL) && (c->type <= UNLANG_TYPE_POLICY)) {
} else if ((c->type > UNLANG_TYPE_MODULE) && (c->type <= UNLANG_TYPE_POLICY)) {
unlang_group_t *g = unlang_generic_to_group(c);
unlang_t *p;
DEBUG("%.*s%s {", indent, "\t\t\t\t\t\t\t\t\t\t\t",
Expand Down Expand Up @@ -908,8 +908,8 @@ static void unlang_dump(unlang_t *mc, int depth)
default:
break;

case UNLANG_TYPE_MODULE_CALL: {
unlang_module_call_t *single = unlang_generic_to_module_call(this);
case UNLANG_TYPE_MODULE: {
unlang_module_t *single = unlang_generic_to_module(this);

DEBUG("%.*s%s", depth, modcall_spaces,
single->module_instance->name);
Expand Down Expand Up @@ -1801,7 +1801,7 @@ static unlang_t *compile_children(unlang_group_t *g, UNUSED unlang_t *parent, un
}
add_child(g, single);

} else if (!parent || (parent->type != UNLANG_TYPE_MODULE_CALL)) {
} else if (!parent || (parent->type != UNLANG_TYPE_MODULE)) {
cf_log_err(cp, "Invalid location for action over-ride");
talloc_free(c);
return NULL;
Expand Down Expand Up @@ -2834,7 +2834,7 @@ static CONF_SECTION *virtual_module_find_cs(CONF_SECTION *conf_root, rlm_compone
static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM *ci, module_instance_t *this, unlang_group_type_t parentgroup_type, char const *realname)
{
unlang_t *c;
unlang_module_call_t *single;
unlang_module_t *single;

/*
* Check if the module in question has the necessary
Expand All @@ -2852,19 +2852,19 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx,
return NULL;
}

single = talloc_zero(parent, unlang_module_call_t);
single = talloc_zero(parent, unlang_module_t);
single->module_instance = this;
single->method = this->module->methods[unlang_ctx->component];

c = unlang_module_call_to_generic(single);
c = unlang_module_to_generic(single);
c->parent = parent;
c->next = NULL;

(void) compile_action_defaults(c, unlang_ctx, parentgroup_type);

c->name = realname;
c->debug_name = realname;
c->type = UNLANG_TYPE_MODULE_CALL;
c->type = UNLANG_TYPE_MODULE;

if (!compile_action_section(c, ci)) {
talloc_free(c);
Expand Down
24 changes: 12 additions & 12 deletions src/unlang/interpret.c
Expand Up @@ -990,14 +990,14 @@ int unlang_event_module_timeout_add(REQUEST *request, fr_unlang_module_timeout_t
unlang_stack_t *stack = request->stack;
unlang_stack_frame_t *frame = &stack->frame[stack->depth];
unlang_event_t *ev;
unlang_module_call_t *sp;
unlang_frame_state_modcall_t *ms = talloc_get_type_abort(frame->state,
unlang_frame_state_modcall_t);
unlang_module_t *sp;
unlang_frame_state_module_t *ms = talloc_get_type_abort(frame->state,
unlang_frame_state_module_t);

rad_assert(stack->depth > 0);
rad_assert((frame->instruction->type == UNLANG_TYPE_MODULE_CALL) ||
rad_assert((frame->instruction->type == UNLANG_TYPE_MODULE) ||
(frame->instruction->type == UNLANG_TYPE_RESUME));
sp = unlang_generic_to_module_call(frame->instruction);
sp = unlang_generic_to_module(frame->instruction);

ev = talloc_zero(request, unlang_event_t);
if (!ev) return -1;
Expand Down Expand Up @@ -1075,15 +1075,15 @@ int unlang_event_fd_add(REQUEST *request,
unlang_stack_t *stack = request->stack;
unlang_stack_frame_t *frame = &stack->frame[stack->depth];
unlang_event_t *ev;
unlang_module_call_t *sp;
unlang_frame_state_modcall_t *ms = talloc_get_type_abort(frame->state,
unlang_frame_state_modcall_t);
unlang_module_t *sp;
unlang_frame_state_module_t *ms = talloc_get_type_abort(frame->state,
unlang_frame_state_module_t);

rad_assert(stack->depth > 0);

rad_assert((frame->instruction->type == UNLANG_TYPE_MODULE_CALL) ||
rad_assert((frame->instruction->type == UNLANG_TYPE_MODULE) ||
(frame->instruction->type == UNLANG_TYPE_RESUME));
sp = unlang_generic_to_module_call(frame->instruction);
sp = unlang_generic_to_module(frame->instruction);

ev = talloc_zero(request, unlang_event_t);
if (!ev) return -1;
Expand Down Expand Up @@ -1439,7 +1439,7 @@ rlm_rcode_t unlang_module_yield(REQUEST *request, fr_unlang_module_resume_t call
REQUEST_VERIFY(request); /* Check the yielded request is sane */

switch (frame->instruction->type) {
case UNLANG_TYPE_MODULE_CALL:
case UNLANG_TYPE_MODULE:
mr = unlang_resume_alloc(request, callback, cancel, rctx);
if (!fr_cond_assert(mr)) {
return RLM_MODULE_FAIL;
Expand All @@ -1448,7 +1448,7 @@ rlm_rcode_t unlang_module_yield(REQUEST *request, fr_unlang_module_resume_t call

case UNLANG_TYPE_RESUME:
mr = talloc_get_type_abort(frame->instruction, unlang_resume_t);
rad_assert(mr->parent->type == UNLANG_TYPE_MODULE_CALL);
rad_assert(mr->parent->type == UNLANG_TYPE_MODULE);

/*
* Re-use the current RESUME frame, but over-ride
Expand Down
32 changes: 16 additions & 16 deletions src/unlang/module.c
Expand Up @@ -49,14 +49,14 @@ static inline void safe_unlock(module_instance_t *instance)
if (instance->mutex) pthread_mutex_unlock(instance->mutex);
}

static unlang_action_t unlang_module_call(REQUEST *request,
static unlang_action_t unlang_module(REQUEST *request,
rlm_rcode_t *presult, int *priority)
{
unlang_module_call_t *sp;
unlang_module_t *sp;
unlang_stack_t *stack = request->stack;
unlang_stack_frame_t *frame = &stack->frame[stack->depth];
unlang_t *instruction = frame->instruction;
unlang_frame_state_modcall_t *ms;
unlang_frame_state_module_t *ms;
int stack_depth = stack->depth;
char const *caller;

Expand All @@ -68,7 +68,7 @@ static unlang_action_t unlang_module_call(REQUEST *request,
* Process a stand-alone child, and fall through
* to dealing with it's parent.
*/
sp = unlang_generic_to_module_call(instruction);
sp = unlang_generic_to_module(instruction);
rad_assert(sp);

RDEBUG4("[%i] %s - %s (%s)", stack->depth, __FUNCTION__,
Expand All @@ -82,7 +82,7 @@ static unlang_action_t unlang_module_call(REQUEST *request,
goto done;
}

frame->state = ms = talloc_zero(stack, unlang_frame_state_modcall_t);
frame->state = ms = talloc_zero(stack, unlang_frame_state_module_t);

/*
* Grab the thread/module specific data if any exists.
Expand Down Expand Up @@ -149,18 +149,18 @@ static unlang_action_t unlang_module_call(REQUEST *request,
* If there is no #fr_unlang_module_signal_t callback defined, the action is ignored.
*
* @param[in] request The current request.
* @param[in] rctx createed by #unlang_module_call.
* @param[in] rctx createed by #unlang_module.
* @param[in] action to signal.
*/
static void unlang_module_signal(REQUEST *request, void *rctx, fr_state_signal_t action)
{
unlang_stack_frame_t *frame;
unlang_stack_t *stack = request->stack;
unlang_resume_t *mr;
unlang_module_call_t *mc;
unlang_module_t *mc;
char const *caller;

unlang_frame_state_modcall_t *ms = NULL;
unlang_frame_state_module_t *ms = NULL;

rad_assert(stack->depth > 0);

Expand All @@ -169,8 +169,8 @@ static void unlang_module_signal(REQUEST *request, void *rctx, fr_state_signal_t
mr = unlang_generic_to_resume(frame->instruction);
if (!mr->signal) return;

mc = unlang_generic_to_module_call(mr->parent);
ms = talloc_get_type_abort(frame->state, unlang_frame_state_modcall_t);
mc = unlang_generic_to_module(mr->parent);
ms = talloc_get_type_abort(frame->state, unlang_frame_state_module_t);

caller = request->module;
request->module = mc->module_instance->name;
Expand All @@ -186,15 +186,15 @@ static unlang_action_t unlang_module_resume(REQUEST *request, rlm_rcode_t *presu
unlang_stack_frame_t *frame = &stack->frame[stack->depth];
unlang_t *instruction = frame->instruction;
unlang_resume_t *mr = unlang_generic_to_resume(instruction);
unlang_module_call_t *mc = unlang_generic_to_module_call(mr->parent);
unlang_module_t *mc = unlang_generic_to_module(mr->parent);
int stack_depth = stack->depth;
char const *caller;

unlang_frame_state_modcall_t *ms = NULL;
unlang_frame_state_module_t *ms = NULL;

rad_assert(mr->parent->type == UNLANG_TYPE_MODULE_CALL);
rad_assert(mr->parent->type == UNLANG_TYPE_MODULE);

ms = talloc_get_type_abort(frame->state, unlang_frame_state_modcall_t);
ms = talloc_get_type_abort(frame->state, unlang_frame_state_module_t);

/*
* Lock is noop unless instance->mutex is set.
Expand Down Expand Up @@ -269,10 +269,10 @@ rlm_rcode_t unlang_module_push_xlat(TALLOC_CTX *ctx, fr_value_box_t **out,

void unlang_module_init(void)
{
unlang_op_register(UNLANG_TYPE_MODULE_CALL,
unlang_op_register(UNLANG_TYPE_MODULE,
&(unlang_op_t){
.name = "module",
.func = unlang_module_call,
.func = unlang_module,
.signal = unlang_module_signal,
.resume = unlang_module_resume
});
Expand Down
12 changes: 6 additions & 6 deletions src/unlang/op.c
Expand Up @@ -52,12 +52,12 @@ static uint64_t unlang_active_callers(unlang_t *instruction)
default:
return 0;

case UNLANG_TYPE_MODULE_CALL:
case UNLANG_TYPE_MODULE:
{
module_thread_instance_t *thread;
unlang_module_call_t *sp;
unlang_module_t *sp;

sp = unlang_generic_to_module_call(instruction);
sp = unlang_generic_to_module(instruction);
rad_assert(sp != NULL);

thread = module_thread_instance_find(sp->module_instance);
Expand Down Expand Up @@ -296,15 +296,15 @@ static unlang_action_t unlang_load_balance(REQUEST *request,
uint64_t active_callers;
unlang_t *child = redundant->child;

if (child->type != UNLANG_TYPE_MODULE_CALL) {
if (child->type != UNLANG_TYPE_MODULE) {
active_callers = unlang_active_callers(child);
RDEBUG3("load-balance child %d sub-section has %" PRIu64 " active", num, active_callers);

} else {
module_thread_instance_t *thread;
unlang_module_call_t *sp;
unlang_module_t *sp;

sp = unlang_generic_to_module_call(child);
sp = unlang_generic_to_module(child);
rad_assert(sp != NULL);

thread = module_thread_instance_find(sp->module_instance);
Expand Down
26 changes: 13 additions & 13 deletions src/unlang/unlang_priv.h
Expand Up @@ -46,13 +46,13 @@ extern "C" {

/** Types of unlang_t nodes
*
* Here are our basic types: unlang_t, unlang_group_t, and unlang_module_call_t. For an
* Here are our basic types: unlang_t, unlang_group_t, and unlang_module_t. For an
* explanation of what they are all about, see doc/configurable_failover.rst
*/
typedef enum {
UNLANG_TYPE_NULL = 0, //!< Modcallable type not set.
UNLANG_TYPE_MODULE_CALL = 1, //!< Module method.
UNLANG_TYPE_FUNCTION, //!< Internal module call to a function or submodule.
UNLANG_TYPE_NULL = 0, //!< unlang type not set.
UNLANG_TYPE_MODULE = 1, //!< Module method.
UNLANG_TYPE_FUNCTION, //!< Internal call to a function or submodule.
UNLANG_TYPE_GROUP, //!< Grouping section.
UNLANG_TYPE_LOAD_BALANCE, //!< Load balance section.
UNLANG_TYPE_REDUNDANT_LOAD_BALANCE, //!< Redundant load balance section.
Expand Down Expand Up @@ -170,7 +170,7 @@ typedef struct {
unlang_t self;
module_instance_t *module_instance; //!< Instance of the module we're calling.
module_method_t method;
} unlang_module_call_t;
} unlang_module_t;

/** Pushed onto the interpreter stack by a yielding module, indicates the resumption point
*
Expand Down Expand Up @@ -218,11 +218,11 @@ typedef struct {

/** A module stack entry
*
* Represents a single module call.
* Represents a single module
*/
typedef struct {
module_thread_instance_t *thread; //!< thread-local data for this module
} unlang_frame_state_modcall_t;
} unlang_frame_state_module_t;

/** State of a foreach loop
*
Expand Down Expand Up @@ -308,25 +308,25 @@ extern char const *const comp2str[];

/** @name Conversion functions for converting #unlang_t to its specialisations
*
* Simple conversions: #unlang_module_call_t and #unlang_group_t are subclasses of #unlang_t,
* Simple conversions: #unlang_module_t and #unlang_group_t are subclasses of #unlang_t,
* so we often want to go back and forth between them.
*
* @{
*/
static inline unlang_module_call_t *unlang_generic_to_module_call(unlang_t *p)
static inline unlang_module_t *unlang_generic_to_module(unlang_t *p)
{
rad_assert(p->type == UNLANG_TYPE_MODULE_CALL);
return talloc_get_type_abort(p, unlang_module_call_t);
rad_assert(p->type == UNLANG_TYPE_MODULE);
return talloc_get_type_abort(p, unlang_module_t);
}

static inline unlang_group_t *unlang_generic_to_group(unlang_t *p)
{
rad_assert((p->type > UNLANG_TYPE_MODULE_CALL) && (p->type <= UNLANG_TYPE_POLICY));
rad_assert((p->type > UNLANG_TYPE_MODULE) && (p->type <= UNLANG_TYPE_POLICY));

return (unlang_group_t *)p;
}

static inline unlang_t *unlang_module_call_to_generic(unlang_module_call_t *p)
static inline unlang_t *unlang_module_to_generic(unlang_module_t *p)
{
return (unlang_t *)p;
}
Expand Down

0 comments on commit 07de411

Please sign in to comment.