Skip to content

Commit

Permalink
use rlm_rcode_t instead of fr_io_final_t
Browse files Browse the repository at this point in the history
in preparation for moving app_process_t function signatures
to match module_method_t

perl -p -i -e 's/fr_io_final_t/rlm_rcode_t/g;s/FR_IO_YIELD/RLM_MODULE_YIELD/g;s/FR_IO_REPLY/RLM_MODULE_OK/g;s/FR_IO_FAIL/RLM_MODULE_FAIL/g;s/FR_IO_DONE/RLM_MODULE_OK/g' $(find src/ -name "*.[ch]" -print)

along with some minor / manual editing.
  • Loading branch information
alandekok committed Sep 23, 2019
1 parent f030322 commit b125950
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 110 deletions.
12 changes: 1 addition & 11 deletions src/lib/io/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ typedef struct {
uint64_t dropped;
} fr_io_stats_t;

/**
* Answer from an async process function if the worker should yield,
* reply, or drop the request.
*/
typedef enum {
FR_IO_YIELD, //!< yielded, request can continue processing
FR_IO_REPLY, //!< please send a reply
FR_IO_FAIL, //!< processing failed somehow, cannot send a reply
FR_IO_DONE, //!< succeeded without a reply
} fr_io_final_t;

typedef struct fr_channel_s fr_channel_t;

Expand Down Expand Up @@ -329,7 +319,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);
typedef rlm_rcode_t (*fr_io_process_t)(void const *instance, REQUEST *request);

/*
* Structures and definitions for the master IO handler.
Expand Down
17 changes: 9 additions & 8 deletions src/lib/io/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
* "time_order" heap, and ages out requests which have been active
* for "too long".
*
* A request may return one of FR_IO_YIELD,
* FR_IO_REPLY, or FR_IO_DONE. If a request is
* A request may return one of RLM_MODULE_YIELD,
* RLM_MODULE_OK, or RLM_MODULE_HANDLED. If a request is
* yeilded, it is placed onto the yielded list in the worker
* "tracking" data structure.
*
Expand Down Expand Up @@ -976,7 +976,7 @@ static REQUEST *fr_worker_get_request(fr_worker_t *worker, fr_time_t now)
static void fr_worker_run_request(fr_worker_t *worker, REQUEST *request)
{
ssize_t size = 0;
fr_io_final_t final;
rlm_rcode_t final;

WORKER_VERIFY;

Expand All @@ -998,30 +998,31 @@ static void fr_worker_run_request(fr_worker_t *worker, REQUEST *request)

} else {
unlang_interpret_signal(request, FR_SIGNAL_CANCEL);
final = FR_IO_DONE;
final = RLM_MODULE_HANDLED;
}

/*
* Figure out what to do next.
*/
switch (final) {
case FR_IO_DONE:
case RLM_MODULE_HANDLED:
/*
* Done: don't send a reply.
*/
break;

case FR_IO_FAIL:
case RLM_MODULE_FAIL:
default:
/*
* Something went wrong. It's done, but we don't send a reply.
*/
break;

case FR_IO_YIELD:
case RLM_MODULE_YIELD:
fr_time_tracking_yield(&request->async->tracking, fr_time(), &worker->tracking);
return;

case FR_IO_REPLY:
case RLM_MODULE_OK:
/*
* Don't reply to internally generated request.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/lib/server/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RCSID("$Id$")
rlm_rcode_t rad_virtual_server(REQUEST *request)
{
VALUE_PAIR *vp, *username, *parent_username = NULL;
fr_io_final_t final;
rlm_rcode_t final;

RDEBUG("Virtual server %s received request", cf_section_name2(request->server_cs));
log_request_pair_list(L_DBG_LVL_1, request, request->packet->vps, NULL);
Expand Down Expand Up @@ -166,7 +166,7 @@ rlm_rcode_t rad_virtual_server(REQUEST *request)
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);
fr_cond_assert(final == RLM_MODULE_OK);

if (!request->reply->code ||
(request->reply->code == FR_CODE_ACCESS_REJECT)) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/unlang/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static unlang_action_t unlang_call(REQUEST *request,

fr_io_process_t *process_p;
void *process_inst;
fr_io_final_t final;
rlm_rcode_t final;

g = unlang_generic_to_group(instruction);
rad_assert(g->children != NULL);
Expand Down Expand Up @@ -252,7 +252,7 @@ static unlang_action_t unlang_call(REQUEST *request,
* we're in a subrequest.
*/
final = child->async->process(child->async->process_inst, child);
if (final == FR_IO_YIELD) {
if (final == RLM_MODULE_YIELD) {
yield:
/*
* Create the "resume" stack frame, and have it replace our stack frame.
Expand Down
8 changes: 4 additions & 4 deletions src/lib/unlang/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ 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)
rlm_rcode_t unlang_io_process_interpret(UNUSED void const *instance, REQUEST *request)
{
rlm_rcode_t rcode;

REQUEST_VERIFY(request);

rcode = unlang_interpret_resume(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

if (rcode == RLM_MODULE_YIELD) return FR_IO_YIELD;
if (rcode == RLM_MODULE_YIELD) return RLM_MODULE_YIELD;

/*
* Don't bother setting request->reply->code.
*/
return FR_IO_DONE;
return RLM_MODULE_HANDLED;
}

/** Allocate a child request based on the parent.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/unlang/unlang_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void unlang_op_free(void);
*
* @{
*/
fr_io_final_t unlang_io_process_interpret(UNUSED void const *instance, REQUEST *request);
rlm_rcode_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);

Expand Down
16 changes: 8 additions & 8 deletions src/modules/proto_detail/proto_detail_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
static rlm_rcode_t mod_process(void const *instance, REQUEST *request)
{
VALUE_PAIR *vp;
rlm_rcode_t rcode;
Expand All @@ -68,7 +68,7 @@ static fr_io_final_t mod_process(void const *instance, REQUEST *request)
unlang = cf_section_find(request->server_cs, "recv", NULL);
if (!unlang) {
REDEBUG("Failed to find 'recv' section");
return FR_IO_FAIL;
return RLM_MODULE_FAIL;
}

RDEBUG("Running 'recv' from file %s", cf_filename(unlang));
Expand All @@ -80,9 +80,9 @@ static fr_io_final_t mod_process(void const *instance, REQUEST *request)
case REQUEST_RECV:
rcode = unlang_interpret_resume(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

if (rcode == RLM_MODULE_YIELD) return FR_IO_YIELD;
if (rcode == RLM_MODULE_YIELD) return RLM_MODULE_YIELD;

rad_assert(request->log.unlang_indent == 0);

Expand Down Expand Up @@ -152,9 +152,9 @@ static fr_io_final_t mod_process(void const *instance, REQUEST *request)
case REQUEST_SEND:
rcode = unlang_interpret_resume(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

if (rcode == RLM_MODULE_YIELD) return FR_IO_YIELD;
if (rcode == RLM_MODULE_YIELD) return RLM_MODULE_YIELD;

rad_assert(request->log.unlang_indent == 0);

Expand Down Expand Up @@ -188,10 +188,10 @@ static fr_io_final_t mod_process(void const *instance, REQUEST *request)
break;

default:
return FR_IO_FAIL;
return RLM_MODULE_FAIL;
}

return FR_IO_REPLY;
return RLM_MODULE_OK;
}


Expand Down
20 changes: 10 additions & 10 deletions src/modules/proto_dhcpv4/proto_dhcpv4_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,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)
static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
{
rlm_rcode_t rcode;
CONF_SECTION *unlang;
Expand All @@ -141,7 +141,7 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
dv = fr_dict_enum_by_value(attr_message_type, fr_box_uint8(request->packet->code));
if (!dv) {
REDEBUG("Failed to find value for &request:DHCP-Message-Type");
return FR_IO_FAIL;
return RLM_MODULE_FAIL;
}

unlang = cf_section_find(request->server_cs, "recv", dv->alias);
Expand All @@ -160,9 +160,9 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
case REQUEST_RECV:
rcode = unlang_interpret_resume(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

if (rcode == RLM_MODULE_YIELD) return FR_IO_YIELD;
if (rcode == RLM_MODULE_YIELD) return RLM_MODULE_YIELD;

rad_assert(request->log.unlang_indent == 0);

Expand Down Expand Up @@ -195,7 +195,7 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
* DHCP-Release / Decline doesn't send a reply, and doesn't run "send DHCP-Do-Not-Respond"
*/
if (!request->reply->code) {
return FR_IO_DONE;
return RLM_MODULE_HANDLED;
}

/*
Expand Down Expand Up @@ -225,9 +225,9 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
case REQUEST_SEND:
rcode = unlang_interpret_resume(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

if (rcode == RLM_MODULE_YIELD) return FR_IO_YIELD;
if (rcode == RLM_MODULE_YIELD) return RLM_MODULE_YIELD;

rad_assert(request->log.unlang_indent == 0);

Expand Down Expand Up @@ -268,17 +268,17 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
*/
if (request->reply->code == FR_DHCP_MESSAGE_TYPE_VALUE_DHCP_DO_NOT_RESPOND) {
RDEBUG("Not sending reply to client");
return FR_IO_DONE;
return RLM_MODULE_HANDLED;
}

if (RDEBUG_ENABLED) dhcpv4_packet_debug(request, request->reply, false);
break;

default:
return FR_IO_FAIL;
return RLM_MODULE_FAIL;
}

return FR_IO_REPLY;
return RLM_MODULE_OK;
}


Expand Down
18 changes: 9 additions & 9 deletions src/modules/proto_radius/proto_radius_acct.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
static rlm_rcode_t mod_process(UNUSED void const *instance, REQUEST *request)
{
VALUE_PAIR *vp;
rlm_rcode_t rcode;
Expand Down Expand Up @@ -82,9 +82,9 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
case REQUEST_RECV:
rcode = unlang_interpret_resume(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

if (rcode == RLM_MODULE_YIELD) return FR_IO_YIELD;
if (rcode == RLM_MODULE_YIELD) return RLM_MODULE_YIELD;

rad_assert(request->log.unlang_indent == 0);

Expand Down Expand Up @@ -139,9 +139,9 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
case REQUEST_PROCESS:
rcode = unlang_interpret_resume(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

if (rcode == RLM_MODULE_YIELD) return FR_IO_YIELD;
if (rcode == RLM_MODULE_YIELD) return RLM_MODULE_YIELD;

rad_assert(request->log.unlang_indent == 0);

Expand Down Expand Up @@ -193,9 +193,9 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
case REQUEST_SEND:
rcode = unlang_interpret_resume(request);

if (request->master_state == REQUEST_STOP_PROCESSING) return FR_IO_DONE;
if (request->master_state == REQUEST_STOP_PROCESSING) return RLM_MODULE_HANDLED;

if (rcode == RLM_MODULE_YIELD) return FR_IO_YIELD;
if (rcode == RLM_MODULE_YIELD) return RLM_MODULE_YIELD;

rad_assert(request->log.unlang_indent == 0);

Expand Down Expand Up @@ -231,10 +231,10 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request)
break;

default:
return FR_IO_FAIL;
return RLM_MODULE_FAIL;
}

return FR_IO_REPLY;
return RLM_MODULE_OK;
}


Expand Down
Loading

0 comments on commit b125950

Please sign in to comment.