From: Alan T. DeKok Date: Thu, 14 Sep 2017 23:29:58 +0000 (-0400) Subject: hack together "call" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ccfce4d148c0d49f6bc6142653f5dd4a186fbcf;p=thirdparty%2Ffreeradius-server.git hack together "call" it doesn't do yeild, and it overloads things it shouldn't overload but it works. It can be cleaned up later --- diff --git a/src/include/interpreter.h b/src/include/interpreter.h index 6c3ef1194dc..2979fc02d08 100644 --- a/src/include/interpreter.h +++ b/src/include/interpreter.h @@ -140,6 +140,7 @@ typedef struct { map_proc_inst_t *proc_inst; //!< Instantiation data for #UNLANG_TYPE_MAP. void const *process; //!< UNLANG_TYPE_CALL }; + CONF_SECTION *server_cs; //!< UNLANG_TYPE_CALL } unlang_group_t; /** A call to a module method diff --git a/src/main/unlang_compile.c b/src/main/unlang_compile.c index e2517f8581d..79ca132c18b 100644 --- a/src/main/unlang_compile.c +++ b/src/main/unlang_compile.c @@ -2661,10 +2661,11 @@ static unlang_t *compile_call(unlang_t *parent, unlang_compile_t *unlang_ctx, CO } g->process = *process_p; + g->server_cs = server_cs; c = unlang_group_to_generic(g); c->name = unlang_ops[c->type].name; - c->debug_name = c->name; + c->debug_name = talloc_asprintf(c, "%s %s", c->name, server); return compile_children(g, parent, unlang_ctx, group_type, parentgroup_type); } diff --git a/src/main/unlang_interpret.c b/src/main/unlang_interpret.c index 4c543346cc2..aff6c9289e9 100644 --- a/src/main/unlang_interpret.c +++ b/src/main/unlang_interpret.c @@ -713,14 +713,50 @@ static unlang_action_t unlang_call(REQUEST *request, unlang_stack_t *stack, unlang_stack_frame_t *frame = &stack->frame[stack->depth]; unlang_t *instruction = frame->instruction; unlang_group_t *g; + int indent; + fr_io_final_t final; + unlang_stack_t *current; + CONF_SECTION *server_cs; g = unlang_generic_to_group(instruction); rad_assert(g->children != NULL); rad_assert(request->async->process == unlang_process_continue); + rad_assert(stack == request->stack); /* probably want to just remove the 'stack' parameter */ - RDEBUG("FAKING CALL TO %s", g->vpt->name); + indent = request->log.unlang_indent; + request->log.unlang_indent = 0; /* the process function expects this */ + current = request->stack; + request->stack = talloc_zero(request, unlang_stack_t); + + server_cs = request->server_cs; + request->server_cs = g->server_cs; + + request->async->process = g->process; + + RDEBUG("server %s {", cf_section_name2(g->server_cs)); + + final = request->async->process(request, FR_IO_ACTION_RUN); + + RDEBUG("} # server %s", cf_section_name2(g->server_cs)); + + /* + * @todo - handle other return codes later. + */ + rad_assert(final == FR_IO_REPLY); + + request->log.unlang_indent = indent; + request->async->process = unlang_process_continue; + talloc_free(request->stack); + request->stack = current; + request->server_cs = server_cs; + + RDEBUG("Continuing with contents of %s { ...", instruction->debug_name); + + /* + * And then call the children to process the answer. + */ unlang_push(stack, g->children, frame->result, UNLANG_NEXT_CONTINUE, UNLANG_SUB_FRAME); return UNLANG_ACTION_PUSHED_CHILD; }