Skip to content

Commit

Permalink
rename unlang functions for clarity
Browse files Browse the repository at this point in the history
running a request is now just unlang_interpret(request)

functions taking more arguments have longer names
  • Loading branch information
alandekok committed Oct 5, 2019
1 parent afc430c commit f36817f
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/lib/server/virtual_servers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ rlm_rcode_t process_authenticate(int auth_type, REQUEST *request)
request->module = NULL;
request->component = "authenticate";

rcode = unlang_interpret(request, cs, RLM_MODULE_REJECT);
rcode = unlang_interpret_section(request, cs, RLM_MODULE_REJECT);

request->component = component;
request->module = module;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/xlat_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
*/
unlang_xlat_push(pool, &result, request, node, true);

switch (unlang_interpret_run(request)) {
switch (unlang_interpret(request)) {
default:
break;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/unlang/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static unlang_action_t unlang_call_child(REQUEST *request, rlm_rcode_t *presult)
* Run the *child* through the "call" section, as a way
* to get post-processing of the packet.
*/
rcode = unlang_interpret_run(child);
rcode = unlang_interpret(child);
if (rcode == RLM_MODULE_YIELD) return UNLANG_ACTION_YIELD;

fr_state_store_in_parent(child, frame->instruction, 0);
Expand Down
24 changes: 7 additions & 17 deletions src/lib/unlang/interpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ static inline unlang_frame_action_t frame_eval(REQUEST *request, unlang_stack_fr
/*
* Interpret the various types of blocks.
*/
rlm_rcode_t unlang_interpret_run(REQUEST *request)
rlm_rcode_t unlang_interpret(REQUEST *request)
{
int priority;
unlang_frame_action_t fa = UNLANG_FRAME_ACTION_NEXT;
Expand All @@ -606,7 +606,7 @@ rlm_rcode_t unlang_interpret_run(REQUEST *request)
unlang_stack_frame_t *frame = &stack->frame[stack->depth]; /* Quiet static analysis */

#ifndef NDEBUG
if (DEBUG_ENABLED5) DEBUG("###### unlang_interpret_run is starting");
if (DEBUG_ENABLED5) DEBUG("###### unlang_interpret is starting");
DUMP_STACK;
#endif

Expand Down Expand Up @@ -808,29 +808,19 @@ void unlang_interpret_push_section(REQUEST *request, CONF_SECTION *cs, rlm_rcode
DUMP_STACK;
}

/** Resume interpreting after a previous push or yield.
*
* @todo - either move to using unlang_interpret_run(), or add sanity
* checks here that the frame was actually yielded.
*/
rlm_rcode_t unlang_interpret_resume(REQUEST *request)
{
return unlang_interpret_run(request);
}

/** Call a module, iteratively, with a local stack, rather than recursively
*
* What did Paul Graham say about Lisp...?
*/
rlm_rcode_t unlang_interpret(REQUEST *request, CONF_SECTION *subcs, rlm_rcode_t default_rcode)
rlm_rcode_t unlang_interpret_section(REQUEST *request, CONF_SECTION *subcs, rlm_rcode_t default_rcode)
{
/*
* This pushes a new frame onto the stack, which is the
* start of a new unlang section...
*/
unlang_interpret_push_section(request, subcs, default_rcode, UNLANG_TOP_FRAME);

return unlang_interpret_run(request);
return unlang_interpret(request);
}

/** Execute an unlang section synchronously
Expand Down Expand Up @@ -875,7 +865,7 @@ rlm_rcode_t unlang_interpret_synchronous(REQUEST *request, CONF_SECTION *cs, rlm
request->el = el;
request->backlog = backlog;

rcode = unlang_interpret(request, cs, action);
rcode = unlang_interpret_section(request, cs, action);
wait_for_events = (rcode == RLM_MODULE_YIELD);

while (true) {
Expand Down Expand Up @@ -933,7 +923,7 @@ rlm_rcode_t unlang_interpret_synchronous(REQUEST *request, CONF_SECTION *cs, rlm
* in the backlog. If this request YIELDs, then
* do another loop around.
*/
sub_rcode = unlang_interpret_resume(sub_request);
sub_rcode = unlang_interpret(sub_request);
if (sub_rcode == RLM_MODULE_YIELD) {
wait_for_events = true;
continue;
Expand Down Expand Up @@ -1086,7 +1076,7 @@ rlm_rcode_t unlang_interpret_stack_result(REQUEST *request)

/** Mark a request as resumable.
*
* It's not called "unlang_interpret_resume", because it doesn't actually
* It's not called "unlang_interpret", because it doesn't actually
* resume the request, it just schedules it for resumption.
*
* @note that this schedules the request for resumption. It does not immediately
Expand Down
4 changes: 2 additions & 2 deletions src/lib/unlang/interpret.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ void unlang_interpret_push_function(REQUEST *request,
void unlang_interpret_push_section(REQUEST *request, CONF_SECTION *cs,
rlm_rcode_t default_action, bool top_frame);

rlm_rcode_t unlang_interpret_resume(REQUEST *request);
rlm_rcode_t unlang_interpret(REQUEST *request);

rlm_rcode_t unlang_interpret(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t default_action);
rlm_rcode_t unlang_interpret_section(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t default_action);

rlm_rcode_t unlang_interpret_synchronous(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t action);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/unlang/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rlm_rcode_t unlang_io_process_interpret(UNUSED void const *instance, REQUEST *re

REQUEST_VERIFY(request);

rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

/*
* We've yielded, and can keep running. Do so.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/unlang/parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static unlang_action_t unlang_parallel_child_done(REQUEST *request, UNUSED rlm_r
*
* Note that we call unlang_interpret_resumable() here
* because unlang_parallel_process() calls
* unlang_interpret_run(), and NOT child->async->process.
* unlang_interpret(), and NOT child->async->process.
*/
if (request->parent) {
child->state = CHILD_EXITED;
Expand Down Expand Up @@ -185,7 +185,7 @@ static unlang_action_t unlang_parallel_process(REQUEST *request, rlm_rcode_t *pr
* kinds of bad things happen. We may
* want to fix that in the future.
*/
result = unlang_interpret_run(state->children[i].child);
result = unlang_interpret(state->children[i].child);
if (result == RLM_MODULE_YIELD) {
state->children[i].state = CHILD_YIELDED;
child_state = CHILD_YIELDED;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/unlang/subrequest.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static unlang_action_t unlang_subrequest_process(REQUEST *request, rlm_rcode_t *

rad_assert(child != NULL);

rcode = unlang_interpret_run(child);
rcode = unlang_interpret(child);
if (rcode != RLM_MODULE_YIELD) {
if (state->session.enable) fr_state_store_in_parent(child,
state->session.unique_ptr,
Expand Down
1 change: 0 additions & 1 deletion src/lib/unlang/unlang_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ static inline unlang_t *unlang_xlat_inline_to_generic(unlang_xlat_inline_t *p)
*/
void unlang_interpret_push(REQUEST *request, unlang_t *instruction,
rlm_rcode_t default_rcode, bool do_next_sibling, bool top_frame);
rlm_rcode_t unlang_interpret_run(REQUEST *request);

int unlang_op_init(void);

Expand Down
2 changes: 1 addition & 1 deletion src/modules/proto_arp/proto_arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static rlm_rcode_t arp_process(REQUEST *request)

request->component = "arp";

return unlang_interpret(request, unlang, RLM_MODULE_NOOP);
return unlang_interpret_section(request, unlang, RLM_MODULE_NOOP);
}


Expand Down
2 changes: 1 addition & 1 deletion src/modules/proto_bfd/proto_bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ static int bfd_process(bfd_state_t *session, bfd_packet_t *bfd)
request->module = NULL;

DEBUG2("server %s {", cf_section_name2(request->server_cs));
unlang_interpret(request, session->unlang, RLM_MODULE_NOTFOUND);
unlang_interpret_section(request, session->unlang, RLM_MODULE_NOTFOUND);
DEBUG("}");

/*
Expand Down
4 changes: 2 additions & 2 deletions src/modules/proto_detail/proto_detail_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static rlm_rcode_t mod_process(void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -150,7 +150,7 @@ static rlm_rcode_t mod_process(void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/proto_dhcpv4/proto_dhcpv4_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -223,7 +223,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
2 changes: 1 addition & 1 deletion src/modules/proto_ldap_sync/proto_ldap_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static void request_running(REQUEST *request, fr_state_signal_t action)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) goto done;

Expand Down
6 changes: 3 additions & 3 deletions src/modules/proto_radius/proto_radius_acct.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -138,7 +138,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_PROCESS:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -192,7 +192,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
6 changes: 3 additions & 3 deletions src/modules/proto_radius/proto_radius_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static rlm_rcode_t mod_process(void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -414,7 +414,7 @@ static rlm_rcode_t mod_process(void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_PROCESS:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -536,7 +536,7 @@ static rlm_rcode_t mod_process(void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/proto_radius/proto_radius_coa.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -160,7 +160,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/proto_radius/proto_radius_dynamic_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -119,7 +119,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/proto_radius/proto_radius_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -123,7 +123,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
6 changes: 3 additions & 3 deletions src/modules/proto_tacacs/proto_tacacs.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static void tacacs_running(REQUEST *request, fr_state_signal_t action)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) {
stop_processing:
Expand Down Expand Up @@ -375,7 +375,7 @@ static void tacacs_running(REQUEST *request, fr_state_signal_t action)
/* FALL-THROUGH */

case REQUEST_PROCESS:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) goto stop_processing;

Expand Down Expand Up @@ -425,7 +425,7 @@ static void tacacs_running(REQUEST *request, fr_state_signal_t action)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) goto stop_processing;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/proto_vmps/proto_vmps_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -128,7 +128,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/proto_vmps/proto_vmps_dynamic_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_RECV:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down Expand Up @@ -121,7 +121,7 @@ static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
/* FALL-THROUGH */

case REQUEST_SEND:
rcode = unlang_interpret_resume(request);
rcode = unlang_interpret(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

Expand Down
Loading

0 comments on commit f36817f

Please sign in to comment.