From: Alan T. DeKok Date: Thu, 16 Jan 2020 20:18:17 +0000 (-0500) Subject: Revert "get rid of request->async->process and move to unlang functions" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=969ba247672ecdb00bbdd5980c42a7af511827fd;p=thirdparty%2Ffreeradius-server.git Revert "get rid of request->async->process and move to unlang functions" This reverts commit 55a07a1571c0ed80a1d83a519f41d694ad566498. --- diff --git a/src/lib/io/listen.h b/src/lib/io/listen.h index 4f0c62eedb1..57a53e5033f 100644 --- a/src/lib/io/listen.h +++ b/src/lib/io/listen.h @@ -47,6 +47,9 @@ struct fr_listen { * Minimal data structure to use the new code. */ struct fr_async_s { + module_method_t process; //!< The current state function. + void *process_inst; //!< Instance data for the current state machine. + fr_time_t recv_time; fr_event_list_t *el; diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index e39929c5a80..3c416588f77 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -505,6 +505,7 @@ finished: #ifndef NDEBUG request->async->el = NULL; + request->async->process = NULL; request->async->channel = NULL; request->async->packet_ctx = NULL; request->async->listen = NULL; @@ -549,6 +550,10 @@ static void worker_stop_request(fr_worker_t *worker, REQUEST *request, fr_time_t if (request->time_order_id >= 0) (void) fr_heap_extract(worker->time_order, request); if (request->runnable_id >= 0) (void) fr_heap_extract(worker->runnable, request); if (request->async->listen->track_duplicates) rbtree_deletebydata(worker->dedup, request); + +#ifndef NDEBUG + request->async->process = NULL; +#endif } /** Enforce max_request_time @@ -717,6 +722,12 @@ nak: */ listen->app->entry_point_set(listen->app_instance, request); + if (!request->async->process) { + RERROR("Protocol failed to set 'process' function"); + worker_nak(worker, cd, now); + return; + } + /* * We're done with this message. */ @@ -854,6 +865,7 @@ redo: fr_time_tracking_resume(&request->async->tracking, now); rad_assert(request->parent == NULL); + rad_assert(request->async->process != NULL); rad_assert(request->async->listen != NULL); rad_assert(request->runnable_id < 0); /* removed from the runnable heap */ @@ -872,7 +884,7 @@ redo: /* * Everything else, run the request. */ - final = unlang_interpret(request); + final = request->async->process(request->async->process_inst, NULL, request); /* * Figure out what to do next. diff --git a/src/lib/server/auth.c b/src/lib/server/auth.c index 680f86e1bc1..861983276ca 100644 --- a/src/lib/server/auth.c +++ b/src/lib/server/auth.c @@ -32,7 +32,6 @@ RCSID("$Id$") #include #include #include -#include #include @@ -153,11 +152,6 @@ rlm_rcode_t rad_virtual_server(REQUEST *request) } runit: -#if 1 - RDEBUG("rad_virtual_server() needs to be fixed to work with the new method"); - final = RLM_MODULE_REJECT; - return final; -#else if (!request->async) { #ifdef __clang_analyzer__ if (!request->parent) return RLM_MODULE_FAIL; @@ -168,20 +162,8 @@ runit: talloc_set_name_const(request->async, talloc_get_name(request->parent->async)); } - /* - * @todo - copy root stack frame from the parent. It - * contains the method to call which processes the - * packet. Now that request->async->process is gone, we - * have to fix this code. - * - * However, if we're running another virtual server, we - * should really be using the unlang "call" - * functionality. That code already looks at the virtual - * server in order to tell the child how to run. - */ - RDEBUG("server %s {", cf_section_name2(request->server_cs)); - final = unlang_interpret(request); + final = request->async->process(request->async->process_inst, NULL, request); RDEBUG("} # server %s", cf_section_name2(request->server_cs)); fr_cond_assert(final == RLM_MODULE_OK); @@ -196,7 +178,6 @@ runit: } return RLM_MODULE_OK; -#endif } /* diff --git a/src/lib/unlang/all.mk b/src/lib/unlang/all.mk index 72a0d605a33..df844508b97 100644 --- a/src/lib/unlang/all.mk +++ b/src/lib/unlang/all.mk @@ -11,7 +11,6 @@ SOURCES := base.c \ io.c \ load_balance.c \ map.c \ - method.c \ module.c \ parallel.c \ return.c \ diff --git a/src/lib/unlang/call.c b/src/lib/unlang/call.c index 2e97a8e5cd1..cfebf0101f4 100644 --- a/src/lib/unlang/call.c +++ b/src/lib/unlang/call.c @@ -27,7 +27,6 @@ RCSID("$Id$") #include #include "unlang_priv.h" #include "subrequest_priv.h" -#include "method.h" /** Send a signal from parent request to subrequest in another virtual server * @@ -75,7 +74,7 @@ static unlang_action_t unlang_call_process(REQUEST *request, rlm_rcode_t *presul * (e.g. Access-Request -> Accounting-Request) unless * we're in a subrequest. */ - rcode = unlang_interpret(child); + rcode = child->async->process(child->async->process_inst, NULL, child); if (rcode == RLM_MODULE_YIELD) { return UNLANG_ACTION_YIELD; } @@ -187,7 +186,8 @@ static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult) * Tell the child how to run. */ child->server_cs = g->server_cs; - unlang_interpret_push_method(child, process_inst, *process_p); + child->async->process = *process_p; + child->async->process_inst = process_inst; /* * Expected by the process functions diff --git a/src/lib/unlang/io.c b/src/lib/unlang/io.c index d41574dce3d..fca77c5655c 100644 --- a/src/lib/unlang/io.c +++ b/src/lib/unlang/io.c @@ -26,7 +26,6 @@ RCSID("$Id$") #include #include "unlang_priv.h" -#include "method.h" /** Run the interpreter after creating a subrequest. * @@ -116,7 +115,7 @@ REQUEST *unlang_io_subrequest_alloc(REQUEST *parent, fr_dict_t const *namespace, * bare-bones function which just runs on section of * "unlang", and doesn't send replies or anything else. */ - unlang_interpret_push_method(child, NULL, unlang_io_process_interpret); + child->async->process = unlang_io_process_interpret; return child; } diff --git a/src/lib/unlang/module.c b/src/lib/unlang/module.c index fed4f52b43d..98e6f7fce13 100644 --- a/src/lib/unlang/module.c +++ b/src/lib/unlang/module.c @@ -383,7 +383,6 @@ void unlang_module_push(rlm_rcode_t *out, REQUEST *request, frame->state = state; } - /** Allocate a subrequest to run through a virtual server at some point in the future * * @param[in] parent to hang sub request off of. diff --git a/src/modules/proto_control/proto_control.c b/src/modules/proto_control/proto_control.c index e6b1992ef43..a958ebde13f 100644 --- a/src/modules/proto_control/proto_control.c +++ b/src/modules/proto_control/proto_control.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "proto_control.h" @@ -116,7 +115,7 @@ static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM * * Future changes may allow different types of control access? */ - return dl_module_instance(ctx, out, listen_cs, parent_inst, "process", DL_MODULE_TYPE_SUBMODULE); + return dl_module_instance(ctx, out, listen_cs, parent_inst, "all", DL_MODULE_TYPE_SUBMODULE); } /** Wrapper around dl_instance @@ -299,10 +298,6 @@ static ssize_t mod_encode(void const *instance, REQUEST *request, uint8_t *buffe return inst->io.app_io->encode(inst->io.app_io_instance, request, buffer, buffer_len); } -/* - * @todo - this function isn't actually used for anything, as - * there is no proto_control_process.c - */ static void mod_entry_point_set(void const *instance, REQUEST *request) { proto_control_t const *inst = talloc_get_type_abort_const(instance, proto_control_t); @@ -318,13 +313,13 @@ static void mod_entry_point_set(void const *instance, REQUEST *request) app_process = (fr_app_worker_t const *) inst->dynamic_submodule->module->common; - unlang_interpret_push_method(request, inst->io.dynamic_submodule->data, app_process->entry_point); + request->async->process = app_process->entry_point; track->dynamic = 0; return; } rad_assert(inst->process != NULL); - unlang_interpret_push_method(request, NULL, inst->process); + request->async->process = inst->process; } diff --git a/src/modules/proto_control/proto_control.h b/src/modules/proto_control/proto_control.h index 892f18edab2..a8468192885 100644 --- a/src/modules/proto_control/proto_control.h +++ b/src/modules/proto_control/proto_control.h @@ -33,8 +33,8 @@ typedef struct { fr_io_instance_t io; //!< wrapper for IO abstraction - dl_module_inst_t **type_submodule; //!< Instance of the various types - dl_module_inst_t *dynamic_submodule; //!< proto_control_dynamic_client + dl_module_inst_t **type_submodule; //!< Instance of the various types + dl_module_inst_t *dynamic_submodule; //!< proto_control_dynamic_client //!< only one instance per type allowed. module_method_t process; //!< process function diff --git a/src/modules/proto_detail/proto_detail.c b/src/modules/proto_detail/proto_detail.c index dddd114372e..447ed4f2402 100644 --- a/src/modules/proto_detail/proto_detail.c +++ b/src/modules/proto_detail/proto_detail.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "proto_detail.h" extern fr_app_t proto_detail; @@ -402,8 +401,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request) app_process = (fr_app_worker_t const *)inst->type_submodule->module->common; request->server_cs = inst->server_cs; - - unlang_interpret_push_method(request, inst->process_instance, app_process->entry_point); + request->async->process = app_process->entry_point; + request->async->process_inst = inst->process_instance; } /** Open listen sockets/connect to external event source diff --git a/src/modules/proto_dhcpv4/proto_dhcpv4.c b/src/modules/proto_dhcpv4/proto_dhcpv4.c index 9b40cb02b03..4a83682fbf4 100644 --- a/src/modules/proto_dhcpv4/proto_dhcpv4.c +++ b/src/modules/proto_dhcpv4/proto_dhcpv4.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "proto_dhcpv4.h" @@ -430,7 +429,7 @@ static void mod_entry_point_set(void const *instance, REQUEST *request) app_process = (fr_app_worker_t const *) inst->io.dynamic_submodule->module->common; - unlang_interpret_push_method(request, inst->io.dynamic_submodule->data, app_process->entry_point); + request->async->process = app_process->entry_point; track->dynamic = 0; return; } @@ -441,7 +440,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request) return; } - unlang_interpret_push_method(request, type_submodule->data, ((fr_app_worker_t const *)type_submodule->module->common)->entry_point); + request->async->process = ((fr_app_worker_t const *)type_submodule->module->common)->entry_point; + request->async->process_inst = type_submodule->data; } diff --git a/src/modules/proto_radius/proto_radius.c b/src/modules/proto_radius/proto_radius.c index 17c41c58982..4349dbcc2e3 100644 --- a/src/modules/proto_radius/proto_radius.c +++ b/src/modules/proto_radius/proto_radius.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "proto_radius.h" @@ -533,7 +532,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request) app_process = (fr_app_worker_t const *) inst->io.dynamic_submodule->module->common; - unlang_interpret_push_method(request, inst->io.dynamic_submodule->data, app_process->entry_point); + request->async->process = app_process->entry_point; + request->async->process_inst = inst->io.dynamic_submodule; track->dynamic = 0; return; } @@ -544,7 +544,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request) return; } - unlang_interpret_push_method(request, type_submodule->data, ((fr_app_worker_t const *)type_submodule->module->common)->entry_point); + request->async->process = ((fr_app_worker_t const *)type_submodule->module->common)->entry_point; + request->async->process_inst = type_submodule->data; } diff --git a/src/modules/proto_vmps/proto_vmps.c b/src/modules/proto_vmps/proto_vmps.c index 26fb9970db8..f393576b29a 100644 --- a/src/modules/proto_vmps/proto_vmps.c +++ b/src/modules/proto_vmps/proto_vmps.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -402,7 +401,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request) app_process = (fr_app_worker_t const *) inst->io.dynamic_submodule->module->common; - unlang_interpret_push_method(request, inst->io.dynamic_submodule->data, app_process->entry_point); + request->async->process = app_process->entry_point; + request->async->process_inst = inst->io.dynamic_submodule; track->dynamic = 0; return; } @@ -413,7 +413,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request) return; } - unlang_interpret_push_method(request, type_submodule->data, ((fr_app_worker_t const *)type_submodule->module->common)->entry_point); + request->async->process = ((fr_app_worker_t const *)type_submodule->module->common)->entry_point; + request->async->process_inst = type_submodule->data; }