Skip to content

Commit

Permalink
Simplify field names
Browse files Browse the repository at this point in the history
Reorder struct definitions in order of use (first last)
  • Loading branch information
arr2036 committed Feb 23, 2020
1 parent b77dacb commit 844e390
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/lib/server/dl_module.c
Expand Up @@ -479,7 +479,6 @@ void *dl_module_instance_symbol(dl_module_inst_t const *dl_inst, char const *sym
}

/** Load a module and parse its #CONF_SECTION in one operation
*
*
* When this instance is no longer needed, it should be freed with talloc_free().
* When all instances of a particular module are unloaded, the dl handle will be closed,
Expand Down
18 changes: 9 additions & 9 deletions src/modules/rlm_radius/rlm_radius.c
Expand Up @@ -391,7 +391,7 @@ static void mod_radius_signal(void *instance, void *thread, REQUEST *request, vo

if (!inst->io->signal) return;

inst->io->signal(request, inst->io_instance, t->thread_io_ctx, rctx, action);
inst->io->signal(request, inst->io_instance, t->io_thread, rctx, action);
}


Expand All @@ -403,7 +403,7 @@ static rlm_rcode_t mod_radius_resume(void *instance, void *thread, REQUEST *requ
rlm_radius_t const *inst = talloc_get_type_abort_const(instance, rlm_radius_t);
rlm_radius_thread_t *t = talloc_get_type_abort(thread, rlm_radius_thread_t);

return inst->io->resume(request, inst->io_instance, t->thread_io_ctx, ctx);
return inst->io->resume(request, inst->io_instance, t->io_thread, ctx);
}

/** Do any RADIUS-layer fixups for proxying.
Expand Down Expand Up @@ -507,7 +507,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_process(void *instance, void *thread, RE
* return another code which indicates what happened to
* the request...b
*/
rcode = inst->io->push(inst->io_instance, request, request_io_ctx, t->thread_io_ctx);
rcode = inst->io->push(inst->io_instance, request, request_io_ctx, t->io_thread);
if (rcode != RLM_MODULE_YIELD) {
talloc_free(request_io_ctx);
return rcode;
Expand All @@ -529,7 +529,7 @@ static int mod_thread_detach(fr_event_list_t *el, void *thread)
* connections.
*/
if (inst->io->thread_detach &&
(inst->io->thread_detach(el, t->thread_io_ctx) < 0)) {
(inst->io->thread_detach(el, t->io_thread) < 0)) {
return -1;
}

Expand All @@ -553,20 +553,20 @@ static int mod_thread_instantiate(UNUSED CONF_SECTION const *cs, void *instance,
* Allocate thread-specific data. The connections should
* live here.
*/
t->thread_io_ctx = talloc_zero_array(t, uint8_t, inst->io->thread_inst_size);
if (!t->thread_io_ctx) return -1;
t->io_thread = talloc_zero_array(t, uint8_t, inst->io->thread_inst_size);
if (!t->io_thread) return -1;

/*
* Set the name of the IO modules thread instance.
*/
if (inst->io->thread_inst_type) (void) talloc_set_name_const(t->thread_io_ctx, inst->io->thread_inst_type);
if (inst->io->thread_inst_type) (void) talloc_set_name_const(t->io_thread, inst->io->thread_inst_type);

/*
* Instantiate the per-thread data. This should open up
* sockets, set timers, etc.
*/
if (inst->io->thread_instantiate &&
inst->io->thread_instantiate(inst->io_conf, inst->io_instance, el, t->thread_io_ctx) < 0) return -1;
inst->io->thread_instantiate(inst->io_conf, inst->io_instance, el, t->io_thread) < 0) return -1;

return 0;
}
Expand All @@ -585,7 +585,7 @@ static int mod_instantiate(void *instance, UNUSED CONF_SECTION *conf)
{
rlm_radius_t *inst = talloc_get_type_abort(instance, rlm_radius_t);

if (inst->io->instantiate(inst->io_instance, inst->io_conf) < 0) return -1;
if (inst->io->instantiate && inst->io->instantiate(inst->io_instance, inst->io_conf) < 0) return -1;

return 0;
}
Expand Down
54 changes: 26 additions & 28 deletions src/modules/rlm_radius/rlm_radius.h
Expand Up @@ -33,32 +33,18 @@
*/

typedef struct rlm_radius_s rlm_radius_t;
typedef struct rlm_radius_io_s rlm_radius_io_t;


/** Push a REQUEST to an IO submodule
*
*/
typedef rlm_rcode_t (*rlm_radius_io_push_t)(void *instance, REQUEST *request, void *request_io_ctx, void *thread);
typedef void (*rlm_radius_io_signal_t)(REQUEST *request, void *instance, void *thread, void *request_io_ctx, fr_state_signal_t action);
typedef int (*rlm_radius_io_instantiate_t)(rlm_radius_t *inst, void *io_instance, CONF_SECTION *cs);


/** Public structure describing an I/O path for an outgoing socket.
/** Per-thread instance data
*
* This structure is exported by client I/O modules e.g. rlm_radius_udp.
* Contains buffers and connection handles specific to the thread.
*/
typedef struct {
DL_MODULE_COMMON; //!< Common fields to all loadable modules.
FR_MODULE_COMMON;
FR_MODULE_THREADED_COMMON;

size_t request_inst_size; //!< size of the data per request
char const *request_inst_type; //!< Talloc type of the request_inst.
rlm_radius_t const *inst; //!< Instance of the module.
fr_event_list_t *el; //!< This thread's event list.

rlm_radius_io_push_t push; //!< push a REQUEST to an IO submodule
rlm_radius_io_signal_t signal; //!< send a signal to an IO module
fr_unlang_module_resume_t resume; //!< resume a request, and get rcode
} rlm_radius_io_t;
void *io_thread; //!< thread context for the IO submodule
} rlm_radius_thread_t;

/*
* Define a structure for our module configuration.
Expand Down Expand Up @@ -94,14 +80,26 @@ struct rlm_radius_s {
fr_trunk_conf_t trunk_conf; //!< trunk configuration
};

/** Push a REQUEST to an IO submodule
*
*/
typedef rlm_rcode_t (*rlm_radius_io_push_t)(void *instance, REQUEST *request, void *request_io_ctx, void *thread);
typedef void (*rlm_radius_io_signal_t)(REQUEST *request, void *instance, void *thread, void *request_io_ctx, fr_state_signal_t action);
typedef int (*rlm_radius_io_instantiate_t)(rlm_radius_t *inst, void *io_instance, CONF_SECTION *cs);

/** Per-thread instance data
/** Public structure describing an I/O path for an outgoing socket.
*
* Contains buffers and connection handles specific to the thread.
* This structure is exported by client I/O modules e.g. rlm_radius_udp.
*/
typedef struct {
rlm_radius_t const *inst; //!< Instance of the module.
fr_event_list_t *el; //!< This thread's event list.
struct rlm_radius_io_s {
DL_MODULE_COMMON; //!< Common fields to all loadable modules.
FR_MODULE_COMMON;
FR_MODULE_THREADED_COMMON;

void *thread_io_ctx; //!< thread context for the IO submodule
} rlm_radius_thread_t;
size_t request_inst_size; //!< size of the data per request
char const *request_inst_type; //!< Talloc type of the request_inst.

rlm_radius_io_push_t push; //!< push a REQUEST to an IO submodule
rlm_radius_io_signal_t signal; //!< send a signal to an IO module
fr_unlang_module_resume_t resume; //!< resume a request, and get rcode
};

0 comments on commit 844e390

Please sign in to comment.