* 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;
#ifndef NDEBUG
request->async->el = NULL;
+ request->async->process = NULL;
request->async->channel = NULL;
request->async->packet_ctx = NULL;
request->async->listen = NULL;
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
*/
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.
*/
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 */
/*
* 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.
#include <freeradius-devel/server/rcode.h>
#include <freeradius-devel/server/state.h>
#include <freeradius-devel/io/listen.h>
-#include <freeradius-devel/unlang/interpret.h>
#include <freeradius-devel/util/print.h>
}
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;
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);
}
return RLM_MODULE_OK;
-#endif
}
/*
io.c \
load_balance.c \
map.c \
- method.c \
module.c \
parallel.c \
return.c \
#include <freeradius-devel/server/state.h>
#include "unlang_priv.h"
#include "subrequest_priv.h"
-#include "method.h"
/** Send a signal from parent request to subrequest in another virtual server
*
* (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;
}
* 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
#include <freeradius-devel/io/listen.h>
#include "unlang_priv.h"
-#include "method.h"
/** Run the interpreter after creating a subrequest.
*
* 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;
}
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.
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/unlang/method.h>
#include <freeradius-devel/server/rad_assert.h>
#include "proto_control.h"
*
* 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
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);
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;
}
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
#include <freeradius-devel/io/schedule.h>
#include <freeradius-devel/io/application.h>
#include <freeradius-devel/server/rad_assert.h>
-#include <freeradius-devel/unlang/method.h>
#include "proto_detail.h"
extern fr_app_t proto_detail;
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
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/unlang/method.h>
#include <freeradius-devel/server/rad_assert.h>
#include "proto_dhcpv4.h"
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;
}
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;
}
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/unlang/method.h>
#include <freeradius-devel/server/rad_assert.h>
#include "proto_radius.h"
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;
}
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;
}
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/unlang/method.h>
#include <freeradius-devel/server/rad_assert.h>
#include <freeradius-devel/protocol/vmps/vmps.h>
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;
}
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;
}