]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
have the worker signal the request directly
authorAlan T. DeKok <aland@freeradius.org>
Fri, 3 May 2019 17:33:47 +0000 (13:33 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 3 May 2019 17:33:47 +0000 (13:33 -0400)
now that everything is integrated, the workers can call unlang
functions.

Since the worker can signal unlang directly, we no longer need
fr_io_action_t, or to pass it as a parameter to the process
functions.

16 files changed:
src/lib/io/base.h
src/lib/io/worker.c
src/lib/server/auth.c
src/lib/server/virtual_servers.h
src/lib/unlang/call.c
src/lib/unlang/io.c
src/lib/unlang/unlang_priv.h
src/modules/proto_detail/proto_detail_process.c
src/modules/proto_dhcpv4/proto_dhcpv4_base.c
src/modules/proto_radius/proto_radius_acct.c
src/modules/proto_radius/proto_radius_auth.c
src/modules/proto_radius/proto_radius_coa.c
src/modules/proto_radius/proto_radius_dynamic_client.c
src/modules/proto_radius/proto_radius_status.c
src/modules/proto_vmps/proto_vmps_all.c
src/modules/proto_vmps/proto_vmps_dynamic_client.c

index abbc787e685a787f0fa56a3a0aea7d1fcc9ad565..f36ee13fbd9e24bc8ee5715335e9d90be9b744bc 100644 (file)
@@ -45,16 +45,6 @@ typedef struct {
        uint64_t        dropped;
 } fr_io_stats_t;
 
-/**
- *  Tell an async process function if it should run or exit.
- */
-typedef enum {
-       FR_IO_ACTION_INVALID = 0,
-       FR_IO_ACTION_RUN,
-       FR_IO_ACTION_DONE,
-       FR_IO_ACTION_DUP,
-} fr_io_action_t;
-
 /**
  *  Answer from an async process function if the worker should yield,
  *  reply, or drop the request.
@@ -339,7 +329,7 @@ typedef int (*fr_io_close_t)(fr_listen_t *li);
  *                             for the #fr_app_worker_t that gave us the
  *                             entry point.
  */
-typedef        fr_io_final_t (*fr_io_process_t)(void const *instance, REQUEST *request, fr_io_action_t action);
+typedef        fr_io_final_t (*fr_io_process_t)(void const *instance, REQUEST *request);
 
 /*
  *     Structures and definitions for the master IO handler.
index 04cb7ae0d2230eab2b4f60f8e6f2a40b80d87363..b19b49303a9b152a5bec9086dd34c595d701b155 100644 (file)
@@ -1013,7 +1013,7 @@ static void fr_worker_run_request(fr_worker_t *worker, REQUEST *request)
        if ((*request->async->original_recv_time == request->async->recv_time) &&
            (request->async->fake ||
             fr_channel_active(request->async->channel))) {
-               final = request->async->process(request->async->process_inst, request, FR_IO_ACTION_RUN);
+               final = request->async->process(request->async->process_inst, request);
 
        } else {
                unlang_interpret_signal(request, FR_SIGNAL_CANCEL);
index 3ba463b231eee919b373a2a906cbc89a59692a51..1368d4dec4f8360b8370d8abc3d39227ac5ea16e 100644 (file)
@@ -159,7 +159,7 @@ runit:
        }
 
        RDEBUG("server %s {", cf_section_name2(request->server_cs));
-       final = request->async->process(request->async->process_inst, request, FR_IO_ACTION_RUN);
+       final = request->async->process(request->async->process_inst, request);
        RDEBUG("} # server %s", cf_section_name2(request->server_cs));
 
        fr_cond_assert(final == FR_IO_REPLY);
index 87b40486ea7d5945c358af6c8411ecc566f28497..f1a5da79f78f598a06b69f357f21848c550f531e 100644 (file)
@@ -89,10 +89,20 @@ bool                listen_record(fr_listen_t *li) CC_HINT(nonnull);
 int fr_app_process_bootstrap(CONF_SECTION *server, dl_instance_t **type_submodule, CONF_SECTION *conf);
 int fr_app_process_instantiate(CONF_SECTION *server, dl_instance_t **type_submodule, dl_instance_t **type_submodule_by_code, int code_max, CONF_SECTION *conf);
 
+
+/** Module methods which are allowed in virtual servers.
+ *
+ */
+typedef struct {
+       char const              *name;
+       char const              *name2;
+} virtual_server_method_t;
+
 typedef struct {
        char const              *name;
        char const              *name2;
        rlm_components_t        component;
+       virtual_server_method_t *methods;
 } virtual_server_compile_t;
 
 #define COMPILE_TERMINATOR { .name = NULL, .name2 = NULL }
index 04b269d928cb1c5a7bc4576db0cdf0b34558a55a..a7e0457d3c6b4c636b03000c4da5e0312230ca71 100644 (file)
@@ -114,7 +114,7 @@ static unlang_action_t unlang_call(REQUEST *request,
         *      (e.g. Access-Request -> Accounting-Request) unless
         *      we're in a subrequest.
         */
-       final = request->async->process(request->async->process_inst, request, FR_IO_ACTION_RUN);
+       final = request->async->process(request->async->process_inst, request);
 
        RDEBUG("} # server %s", server);
 
index 7d86892ca4e01448b323408c71677a2bf4b336dc..39abfa279fabd8dc6678deca42b11d9d8c9211b6 100644 (file)
@@ -33,21 +33,12 @@ RCSID("$Id$")
  *
  * This is a shim function added to 'fake' requests by the subrequest and parallel keywords.
  */
-fr_io_final_t unlang_io_process_interpret(UNUSED void const *instance, REQUEST *request, fr_io_action_t action)
+fr_io_final_t unlang_io_process_interpret(UNUSED void const *instance, REQUEST *request)
 {
        rlm_rcode_t rcode;
 
        REQUEST_VERIFY(request);
 
-       /*
-        *      Pass this through asynchronously to the module which
-        *      is waiting for something to happen.
-        */
-       if (action != FR_IO_ACTION_RUN) {
-               unlang_interpret_signal(request, (fr_state_signal_t) action);
-               return FR_IO_DONE;
-       }
-
        rcode = unlang_interpret_resume(request);
 
        if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
index ba51f21cb805638d7f0ea3093611b17bf44bc903..a404347c2eac5e7b10ad17c69b89f99027281326 100644 (file)
@@ -357,7 +357,7 @@ void                unlang_op_free(void);
  *
  * @{
  */
-fr_io_final_t  unlang_io_process_interpret(UNUSED void const *instance, REQUEST *request, fr_io_action_t action);
+fr_io_final_t  unlang_io_process_interpret(UNUSED void const *instance, REQUEST *request);
 
 REQUEST                *unlang_io_subrequest_alloc(REQUEST *parent, fr_dict_t const *namespace, bool detachable);
 
index 04851cbddcaae067bfb2b3fcd3dc410076ddeeb6..ca2e768b0f36780c048b3dbeb3bb2146098744c9 100644 (file)
@@ -47,7 +47,7 @@ fr_dict_attr_autoload_t proto_detail_process_dict_attr[] = {
        { NULL }
 };
 
-static fr_io_final_t mod_process(void const *instance, REQUEST *request, fr_io_action_t action)
+static fr_io_final_t mod_process(void const *instance, REQUEST *request)
 {
        VALUE_PAIR                      *vp;
        rlm_rcode_t                     rcode;
@@ -56,15 +56,6 @@ static fr_io_final_t mod_process(void const *instance, REQUEST *request, fr_io_a
 
        REQUEST_VERIFY(request);
 
-       /*
-        *      Pass this through asynchronously to the module which
-        *      is waiting for something to happen.
-        */
-       if (action != FR_IO_ACTION_RUN) {
-               unlang_interpret_signal(request, (fr_state_signal_t) action);
-               return FR_IO_DONE;
-       }
-
        switch (request->request_state) {
        case REQUEST_INIT:
                RDEBUG("Received %s ID %i",
index f419b7922b21553d7d4fb16ad36078978043daf0..06ad3ac3366a62f9e4081c8e4531db49fe7d3117 100644 (file)
@@ -119,7 +119,7 @@ static void dhcpv4_packet_debug(REQUEST *request, RADIUS_PACKET *packet, bool re
        }
 }
 
-static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request, UNUSED fr_io_action_t action)
+static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
 {
        rlm_rcode_t rcode;
        CONF_SECTION *unlang;
index 25728908b0e8b93d9365a021540f5a397ddb0576..0f8ac54b12ac0c9e1901e599c32326741f54b353 100644 (file)
@@ -48,7 +48,7 @@ fr_dict_attr_autoload_t proto_radius_acct_dict_attr[] = {
 };
 
 
-static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request, fr_io_action_t action)
+static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
 {
        VALUE_PAIR      *vp;
        rlm_rcode_t     rcode;
@@ -57,15 +57,6 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
 
        REQUEST_VERIFY(request);
 
-       /*
-        *      Pass this through asynchronously to the module which
-        *      is waiting for something to happen.
-        */
-       if (action != FR_IO_ACTION_RUN) {
-               unlang_interpret_signal(request, (fr_state_signal_t) action);
-               return FR_IO_DONE;
-       }
-
        switch (request->request_state) {
        case REQUEST_INIT:
                if (request->parent && RDEBUG_ENABLED) {
index e39cbabcd720bc1d296ef03c126ce631deeff66c..58b49b1c5d845c683fae7461dcfdb33cadd7a772 100644 (file)
@@ -240,7 +240,7 @@ static void CC_HINT(format (printf, 4, 5)) auth_message(proto_radius_auth_t cons
        talloc_free(msg);
 }
 
-static fr_io_final_t mod_process(void const *instance, REQUEST *request, fr_io_action_t action)
+static fr_io_final_t mod_process(void const *instance, REQUEST *request)
 {
        proto_radius_auth_t const       *inst = instance;
        VALUE_PAIR                      *vp, *auth_type;
@@ -251,15 +251,6 @@ static fr_io_final_t mod_process(void const *instance, REQUEST *request, fr_io_a
 
        REQUEST_VERIFY(request);
 
-       /*
-        *      Pass this through asynchronously to the module which
-        *      is waiting for something to happen.
-        */
-       if (action != FR_IO_ACTION_RUN) {
-               unlang_interpret_signal(request, (fr_state_signal_t) action);
-               return FR_IO_DONE;
-       }
-
        switch (request->request_state) {
        case REQUEST_INIT:
                if (request->parent && RDEBUG_ENABLED) {
index 316e8f8cacf1be91f93925ba47ba5e204da1dc11..aa56772b9f7c1e708e298a4e7bfc6dafe4dc1d7c 100644 (file)
@@ -49,7 +49,7 @@ fr_dict_attr_autoload_t proto_radius_coa_dict_attr[] = {
        { NULL }
 };
 
-static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request, fr_io_action_t action)
+static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
 {
        VALUE_PAIR *vp;
        rlm_rcode_t rcode;
@@ -58,15 +58,6 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
 
        REQUEST_VERIFY(request);
 
-       /*
-        *      Pass this through asynchronously to the module which
-        *      is waiting for something to happen.
-        */
-       if (action != FR_IO_ACTION_RUN) {
-               unlang_interpret_signal(request, (fr_state_signal_t) action);
-               return FR_IO_DONE;
-       }
-
        switch (request->request_state) {
        case REQUEST_INIT:
                if (request->parent && RDEBUG_ENABLED) {
index bd9c1e24eade01938f386f94b87236c896c285ef..7f78da84a2f4bb49af2db3163807d17005778577 100644 (file)
@@ -57,22 +57,13 @@ fr_dict_attr_autoload_t proto_radius_dynamic_client_dict_attr[] = {
        { NULL }
 };
 
-static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request, fr_io_action_t action)
+static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
 {
        rlm_rcode_t rcode;
        CONF_SECTION *unlang;
 
        REQUEST_VERIFY(request);
 
-       /*
-        *      Pass this through asynchronously to the module which
-        *      is waiting for something to happen.
-        */
-       if (action != FR_IO_ACTION_RUN) {
-               unlang_interpret_signal(request, (fr_state_signal_t) action);
-               return FR_IO_DONE;
-       }
-
        switch (request->request_state) {
        case REQUEST_INIT:
                request->component = "radius";
index 40d54235d9a92d3c1b65b41d52274d486d553611..3076b90a769a9bb5ea32c5990a75d5454b52fb8d 100644 (file)
@@ -45,7 +45,7 @@ fr_dict_attr_autoload_t proto_radius_status_dict_attr[] = {
        { NULL }
 };
 
-static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request, fr_io_action_t action)
+static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
 {
        rlm_rcode_t rcode;
        CONF_SECTION *unlang;
@@ -54,15 +54,6 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
 
        REQUEST_VERIFY(request);
 
-       /*
-        *      Pass this through asynchronously to the module which
-        *      is waiting for something to happen.
-        */
-       if (action != FR_IO_ACTION_RUN) {
-               unlang_interpret_signal(request, (fr_state_signal_t) action);
-               return FR_IO_DONE;
-       }
-
        switch (request->request_state) {
        case REQUEST_INIT:
                if (request->parent && RDEBUG_ENABLED) {
index 327d31359a3adb1e6d611f235b48c38d66c808e9..682a70b37d0906c4441e41d477b1bbf0e6258305 100644 (file)
@@ -48,7 +48,7 @@ fr_dict_attr_autoload_t proto_vmps_all_dict_attr[] = {
        { NULL }
 };
 
-static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request, UNUSED fr_io_action_t action)
+static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
 {
        rlm_rcode_t             rcode;
        CONF_SECTION            *unlang;
index 498281bbc94991c7bf7414dfd4f2cf691534c222..eb631bd49c55aaf87875d051609b437f83163184 100644 (file)
@@ -57,22 +57,13 @@ fr_dict_attr_autoload_t proto_vmps_dynamic_client_dict_attr[] = {
 #define CLIENT_ADD     (1)
 #define CLIENT_NAK     (257)
 
-static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request, fr_io_action_t action)
+static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
 {
        rlm_rcode_t rcode;
        CONF_SECTION *unlang;
 
        REQUEST_VERIFY(request);
 
-       /*
-        *      Pass this through asynchronously to the module which
-        *      is waiting for something to happen.
-        */
-       if (action != FR_IO_ACTION_RUN) {
-               unlang_interpret_signal(request, (fr_state_signal_t) action);
-               return FR_IO_DONE;
-       }
-
        switch (request->request_state) {
        case REQUEST_INIT:
                RDEBUG("Received %s ID %i", fr_vmps_codes[request->packet->code], request->packet->id);