]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove "inst" from timeout / FD add
authorAlan T. DeKok <aland@freeradius.org>
Sat, 26 Nov 2016 21:44:38 +0000 (16:44 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 26 Nov 2016 21:44:38 +0000 (16:44 -0500)
because the module instance is already on the stack

src/include/modules.h
src/main/unlang.c
src/modules/rlm_delay/rlm_delay.c
src/modules/rlm_radius_client/rlm_radius_client.c

index 970f8fb876a988a0b5416bc01876f94f8a6f3f7f..cdee09f8324469666d22bcef3e133d961ccac288 100644 (file)
@@ -271,10 +271,10 @@ typedef rlm_rcode_t (*fr_unlang_resume_t)(REQUEST *request, void *module_instanc
 typedef void (*fr_unlang_action_t)(REQUEST *request, void *module_instance, void *ctx, fr_state_action_t action);
 
 int            unlang_event_timeout_add(REQUEST *request, fr_unlang_timeout_callback_t callback,
-                                        void const *module_instance, void const *ctx, struct timeval *timeout);
+                                        void const *ctx, struct timeval *timeout);
 
 int            unlang_event_fd_readable_add(REQUEST *request, fr_unlang_fd_callback_t callback,
-                                            void const *module_instance, void const *ctx, int fd);
+                                            void const *ctx, int fd);
 
 int            unlang_event_timeout_delete(REQUEST *request, void const *ctx);
 
index 494cf7a29f5d094bcdb87c21b298a947d71b745d..ad91f73fff8393f87e8ea8c54aedd62f99531f79 100644 (file)
@@ -1349,7 +1349,6 @@ static void unlang_event_fd_handler(UNUSED fr_event_list_t *el, int fd, void *ct
  *
  * param[in] request           the current request.
  * param[in] callback          to call.
- * param[in] inst              The module instance
  * param[in] ctx               for the callback.
  * param[in] timeout           when to call the timeout (i.e. now + timeout).
  * @return
@@ -1357,17 +1356,19 @@ static void unlang_event_fd_handler(UNUSED fr_event_list_t *el, int fd, void *ct
  *     - <0 on error.
  */
 int unlang_event_timeout_add(REQUEST *request, fr_unlang_timeout_callback_t callback,
-                            void const *inst, void const *ctx, struct timeval *when)
+                            void const *ctx, struct timeval *when)
 {
        unlang_stack_frame_t    *frame;
        unlang_stack_t          *stack = request->stack;
-       unlang_event_t *ev;
+       unlang_event_t          *ev;
+       unlang_module_call_t    *sp;
 
        rad_assert(stack->depth > 0);
 
        frame = &stack->frame[stack->depth];
 
        rad_assert(frame->instruction->type == UNLANG_TYPE_MODULE_CALL);
+       sp = unlang_generic_to_module_call(frame->instruction);
 
        ev = talloc_zero(request, unlang_event_t);
        if (!ev) return -1;
@@ -1375,7 +1376,7 @@ int unlang_event_timeout_add(REQUEST *request, fr_unlang_timeout_callback_t call
        ev->request = request;
        ev->fd = -1;
        ev->timeout_callback = callback;
-       ev->inst = inst;
+       ev->inst = sp->module_instance->data;
        ev->ctx = ctx;
 
        if (fr_event_timer_insert(request->el, unlang_event_timeout_handler, ev, when, &(ev->ev)) < 0) {
@@ -1400,7 +1401,6 @@ int unlang_event_timeout_add(REQUEST *request, fr_unlang_timeout_callback_t call
  *
  * @param[in] request          The current request.
  * @param[in] callback         to call.
- * @param[in] inst             The module instance
  * @param[in] ctx              for the callback.
  * @param[in] fd               to watch.  When it becomes readable the request is marked as resumable,
  *                             with the callback being called by the worker responsible for processing
@@ -1410,17 +1410,19 @@ int unlang_event_timeout_add(REQUEST *request, fr_unlang_timeout_callback_t call
  *     - <0 on error.
  */
 int unlang_event_fd_readable_add(REQUEST *request, fr_unlang_fd_callback_t callback,
-                                void const *inst, void const *ctx, int fd)
+                                void const *ctx, int fd)
 {
        unlang_stack_frame_t    *frame;
        unlang_stack_t          *stack = request->stack;
-       unlang_event_t *ev;
+       unlang_event_t          *ev;
+       unlang_module_call_t    *sp;
 
        rad_assert(stack->depth > 0);
 
        frame = &stack->frame[stack->depth];
 
        rad_assert(frame->instruction->type == UNLANG_TYPE_MODULE_CALL);
+       sp = unlang_generic_to_module_call(frame->instruction);
 
        ev = talloc_zero(request, unlang_event_t);
        if (!ev) return -1;
@@ -1428,7 +1430,7 @@ int unlang_event_fd_readable_add(REQUEST *request, fr_unlang_fd_callback_t callb
        ev->request = request;
        ev->fd = fd;
        ev->fd_callback = callback;
-       ev->inst = inst;
+       ev->inst = sp->module_instance->data;
        ev->ctx = ctx;
 
        if (!fr_event_fd_insert(request->el, fd, unlang_event_fd_handler, NULL, NULL, ev)) {
index d7aadf458f0049c6bbffeb0e00e09cc67ebe7db0..7bed823573884b66d881fefe9c7b44a5151d5a5e 100644 (file)
@@ -134,7 +134,7 @@ static rlm_rcode_t delay_add(rlm_delay_t const *inst, REQUEST *request)
                RDEBUG2("Rescheduling request");
        }
 
-       if (unlang_event_timeout_add(request, delay_done, inst, now, &when) < 0) return RLM_MODULE_FAIL;
+       if (unlang_event_timeout_add(request, delay_done, now, &when) < 0) return RLM_MODULE_FAIL;
 
        return RLM_MODULE_YIELD;
 }
index 0ddc070cd60a483b4f774d68802cdab2f22cb84b..75157206f8f7e0619a3df591447fb3fcc828b277 100644 (file)
@@ -423,7 +423,7 @@ static rlm_rcode_t mod_wait_for_reply(REQUEST *request, rlm_radius_client_instan
        gettimeofday(&now, NULL);
        fr_timeval_add(&timeout, &now, &timeout);
 
-       unlang_event_timeout_add(request, mod_proxy_no_reply, inst, ccr, &timeout);
+       unlang_event_timeout_add(request, mod_proxy_no_reply, ccr, &timeout);
 
        return unlang_yield(request, mod_resume_continue, mod_action_dup, ccr);
 }