mod_instantiate instance variable 2.2.4 vs 3.0.9

Arran Cudbard-Bell a.cudbardb at freeradius.org
Sat Sep 5 22:21:33 CEST 2015


> On 5 Sep 2015, at 15:50, Richard Levenberg <richardl at ufp.com> wrote:
> 
> In converting my module development efforts from 2.2.4 to 3.0.9 to make
> use of the v3, "session-state" I noticed a difference in mod_instantiate
> where the instance variable is passed as *instance rather than
> **instance. I don't need to keep around any of the configuration
> information, I only use it to get a pointer into a library object that I
> can subsequently use with mod_authorize and mod_authenticate.

void *instance points to a talloced chunk of memory, of size module_t->inst_size

You can store whatever you like in it.

If you want to store a pointer to a library handle .inst_size = sizeof(lib_handle_type_t *)

In instantiate:

	<lib_handle_type_t> **handle = (void **)instance;

	*handle = my_library_init();

In the other section functions:

	<lib_handle_type_t> *handle = *instance;

> So in 3.0.9 is it just assumed that you will carry around config via the
> instance variable that you don't need.

At the cost of a whole 8 bytes of memory, yes.  It makes instantiation much simpler for the majority of modules.

Making 3rd party developers who have no plans of contributing their code back to the project, happy, is not a priority.  Making it easier for the core team to write and maintain bundled modules, is.

> I see in rlm_example.c the comment: "
> *	If configuration information is given in the config section
> *	that must be referenced in later calls, store a handle to it
> *	in *instance otherwise put a null pointer there.
> "
> 
> But I'm not clear what that comment means nor how to reset the instance
> variable pointer to the actual thing I need to keep around.

I'll remove the comment, it only applies to v2.x.x.

Arran Cudbard-Bell <a.cudbardb at freeradius.org>
FreeRADIUS development team

FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 872 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freeradius.org/pipermail/freeradius-devel/attachments/20150905/0de5db4d/attachment.sig>


More information about the Freeradius-Devel mailing list