From: Alan T. DeKok Date: Sat, 26 Nov 2016 21:44:38 +0000 (-0500) Subject: remove "inst" from timeout / FD add X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb57752d7c7e7345caa755326ed42059dd095346;p=thirdparty%2Ffreeradius-server.git remove "inst" from timeout / FD add because the module instance is already on the stack --- diff --git a/src/include/modules.h b/src/include/modules.h index 970f8fb876a..cdee09f8324 100644 --- a/src/include/modules.h +++ b/src/include/modules.h @@ -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); diff --git a/src/main/unlang.c b/src/main/unlang.c index 494cf7a29f5..ad91f73fff8 100644 --- a/src/main/unlang.c +++ b/src/main/unlang.c @@ -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)) { diff --git a/src/modules/rlm_delay/rlm_delay.c b/src/modules/rlm_delay/rlm_delay.c index d7aadf458f0..7bed8235738 100644 --- a/src/modules/rlm_delay/rlm_delay.c +++ b/src/modules/rlm_delay/rlm_delay.c @@ -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; } diff --git a/src/modules/rlm_radius_client/rlm_radius_client.c b/src/modules/rlm_radius_client/rlm_radius_client.c index 0ddc070cd60..75157206f8f 100644 --- a/src/modules/rlm_radius_client/rlm_radius_client.c +++ b/src/modules/rlm_radius_client/rlm_radius_client.c @@ -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); }