#6 nunc-stans config struct should be protected with an initializer
Closed: Fixed None Opened 8 years ago by rmeggins.

copied from https://fedorahosted.org/389/ticket/48043

If you just do
{{{
struct ns_thrpool_config config;
ns_thrpool_new(&config);
}}}
you will get a lot of problems. Or if you only want to set certain parameters and leave the other ones as their default values. There should be a new function - ns_thrpool_config_init(&config). This will set the config values to their defaults, and will set a flag in the config structure:
{{{
ns_thrpool.h:
struct ns_thrpool_config {
int init_flag; / if set to the magic value, has been initialized properly /
...
}

ns_thrpool.c:

define NS_INIT_MAGIC 0xdefa014

void
ns_thrpool_config_init(*config)
{
... set default values ...
config->init_flag = NS_INIT_MAGIC;
return;
}

PRStatus
ns_thrpool_new(*config)
{
if (config->init_flag != NS_INIT_MAGIC) {
log_something(error, not initialized properly);
return PR_FAILURE;
}
}
}}}

That way, the config struct must be initialized properly, unless the user goes out of the way to find the init_flag and set it.

commit 010992fd049811deb771e9db0ee73e5e0033ed2e


Login to comment on this ticket.

Metadata