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

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.


To git+ssh://git.engineering.redhat.com/srv/git/users/mareynol/nunc-stans.git
c89dcbf..010992f mreynolds -> mreynolds
commit 010992fd049811deb771e9db0ee73e5e0033ed2e

To git+ssh://git.engineering.redhat.com/srv/git/users/mareynol/ds.git
5ab764a..8db3d1a nunc-stans -> nunc-stans
commit 8db3d1a65267df14af323b5ef89c44ce003198f9

Metadata Update from @mreynolds:
- Issue assigned to mreynolds
- Issue set to the milestone: 1.3.4 backlog

3 years ago

Login to comment on this ticket.

Metadata