[asterisk-dev] [Code Review] Provide means to notify manager sessions that all modules have finished loading

Terry Wilson twilson at digium.com
Tue May 4 21:49:27 CDT 2010



> On 2010-05-04 04:06:48, Nick Lewis wrote:
> > Can any AMI solution be easily extended to the CLI too? I have had problems with valgrind running CLI unit tests such as "test execute category channels/chan_sip name sip_parse_register_line_test" because relevant modules have not yet loaded.

Perhaps we could add a CLI command that basically loops until the FULLY_BOOTED flag is set, then returns when it is successful. Then just run that CLI command before running any other tests?
Something like:


static char *handle_waitformodules(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
    switch (cmd) {
    case CLI_INIT:
        e->command = "core waitformodules";
        e->usage =
            "Usage: core waitformodules\n"
            "       Wait until all modules are loaded.\n";
        return NULL;
    case CLI_GENERATE:
        return NULL;
    }

    while (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
        usleep(100);
    }

    ast_cli(a->fd, "All Asterisk modules have loaded\n");
    return CLI_SUCCESS;
}


- Terry


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/639/#review1952
-----------------------------------------------------------


On 2010-05-01 01:35:28, Terry Wilson wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/639/
> -----------------------------------------------------------
> 
> (Updated 2010-05-01 01:35:28)
> 
> 
> Review request for Asterisk Developers and Russell Bryant.
> 
> 
> Summary
> -------
> 
> It is possible to connect to Asterisk via the manager interface before all of the modules are finished loading. This can lead to manager actions failing because a necessary module hasn't loaded yet. One area where this is really annoying is when writing external tests.
> 
> This small patch adds a FullyBooted manager event which fires when Asterisk is finished loading the modules. Since it is possible that one would miss this event, it is also sent upon login if Asterisk is fully booted.
> 
> I also propose that we add this to all branches to aid in testing. For existing releases, I think it should be disabled by default and enabled via an asterisk.conf setting to avoid any behavior changes.
> 
> In the very unlikely event that someone successfully authenticates between setting of AST_OPT_FLAG_FULLY_BOOTED and the sending of the manager_event in asterisk.c, they would get two FullyBooted events. Personally, I'm Ok with that since we really only care whether or not Asterisk is fully booted or not. I can't think of any circumstances where we could actually miss a FullyBooted event, though, which is the important thing. If we need to bother with locking, we can do that too of course. :-)
> 
> 
> Diffs
> -----
> 
>   /trunk/main/asterisk.c 260520 
>   /trunk/main/manager.c 260520 
> 
> Diff: https://reviewboard.asterisk.org/r/639/diff
> 
> 
> Testing
> -------
> 
> Connected and verified that the Event fires (and that a well placed sleep() makes it fire twice). 
> 
> 
> Thanks,
> 
> Terry
> 
>




More information about the asterisk-dev mailing list