]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 265320,265467 via svnmerge from
authorTerry Wilson <twilson@digium.com>
Mon, 24 May 2010 23:25:58 +0000 (23:25 +0000)
committerTerry Wilson <twilson@digium.com>
Mon, 24 May 2010 23:25:58 +0000 (23:25 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

........
  r265320 | twilson | 2010-05-24 14:06:40 -0500 (Mon, 24 May 2010) | 14 lines

  Add the FullyBooted AMI event

  It is possible to connect to the manager interface before all Asterisk modules
  are loaded. To ensure that an application does not send AMI actions that might
  require a module that has not yet loaded, the application can listen for the
  FullyBooted manager event. It will be sent upon connection if all modules have
  been loaded, or as soon as loading is complete. The event:

     Event: FullyBooted
     Privilege: system,all
     Status: Fully Booted

  Review: https://reviewboard.asterisk.org/r/639/
........
  r265467 | twilson | 2010-05-24 17:21:58 -0500 (Mon, 24 May 2010) | 1 line

  Merge the rest of the FullyBooted patch
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@265519 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
doc/manager_1_1.txt
doc/tex/manager.tex
include/asterisk/options.h
main/asterisk.c
main/manager.c

index 3e1ff63c96703f64664b48c133bec98f7ccdbfcb..e6dcfa583f2276b37fc35a90e8eb01af19215f62 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -691,6 +691,7 @@ samples: adsi
                echo "                        ; to the device.  It is for this reason that this is optional, as it may result in requiring a" ; \
                echo "                        ; temporary codec translation path for a channel that may not otherwise require one." ; \
                echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
+               echo ";sendfullybooted = yes  ; Send the FullyBooted AMI event on AMI login and when all modules are finished loading" ; \
                echo ";runuser = asterisk ; The user to run as" ; \
                echo ";rungroup = asterisk ; The group to run as" ; \
                echo "" ; \
index 8de37e591e66821d86b6ba34d3c4830968d5c75c..09b6d91e0aceb278064b3f6824fc42de83bc7c70 100644 (file)
@@ -200,6 +200,22 @@ Changes to manager version 1.1:
 * NEW EVENTS
 ------------
 
+- Event: FullyBooted
+       Modules: loader.c
+       Purpose:
+               It is handy to have a single event notification for when all Asterisk
+               modules have been loaded--especially for situations like running
+               automated tests. This event will fire 1) immediately upon all modules
+               loading or 2) upon connection to the AMI interface if the modules have
+               already finished loading before the connection was made. This ensures
+               that a user will never miss getting a FullyBooted event. In vary rare
+               circumstances, it might be possible to get two copies of the message
+               if the AMI connection is made right as the modules finish loading.
+       Example:
+               Event: FullyBooted
+               Privilege: system,all
+               Status: Fully Booted
+
 - Event: Transfer
        Modules: res_features, chan_sip
        Purpose:
index 1f9fa1495dab2e4984fcb8f9c7d3619a2d0e5847..7235ca447501599ffa3cdc9898b0d5fec34f4549 100644 (file)
@@ -28,8 +28,6 @@ If you develop applications, please try to reuse existing manager
 headers and their interpretation. If you are unsure, discuss on
 the asterisk-dev mailing list.
 
-\section{Device status reports}
-
 Manager subscribes to extension status reports from all channels,
 to be able to generate events when an extension or device changes
 state. The level of details in these events may depend on the channel
@@ -111,6 +109,21 @@ There are a number of GUI tools that use the manager interface, please search
 the mailing list archives and the documentation page on the
 \url{http://www.asterisk.org} web site for more information.
 
+\section{Ensuring all modules are loaded}
+It is possible to connect to the manager interface before all Asterisk modules
+are loaded. To ensure that an application does not send AMI actions that might
+require a module that has not yet loaded, the application can listen for the
+FullyBooted manager event. It will be sent upon connection if all modules have
+been loaded, or as soon as loading is complete. The event:
+
+\begin{verbatim}
+   Event: FullyBooted
+   Privilege: system,all
+   Status: Fully Booted
+\end{verbatim}
+
+\section{Device status reports}
+
 
 \section{Some standard AMI headers}
 \begin{verbatim}
index 3d6f89ceb1511c163444caef09e3e445a0c9d5da..5d6b842798ce8e7032de68bb1d7b7d8712b9d4eb 100644 (file)
@@ -82,6 +82,8 @@ enum ast_option_flags {
        AST_OPT_FLAG_DEBUG_FILE = (1 << 23),
        /*! There is a per-file verbose setting */
        AST_OPT_FLAG_VERBOSE_FILE = (1 << 24),
+       /*! Send the FullyBooted AMI event when all modules are loaded */
+       AST_OPT_FLAG_SEND_FULLYBOOTED = (1 << 25),
 };
 
 /*! These are the options that set by default when Asterisk starts */
@@ -111,6 +113,7 @@ enum ast_option_flags {
 #define ast_opt_mute                   ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)
 #define ast_opt_dbg_file               ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_FILE)
 #define ast_opt_verb_file              ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_FILE)
+#define ast_opt_send_fullybooted       ast_test_flag(&ast_options, AST_OPT_FLAG_SEND_FULLYBOOTED)
 
 extern struct ast_flags ast_options;
 
index fcf9a5a75d1b975a7a78f16560fbf40024dda082..012a5c19ce07aee071752b0750a183c85727a3d9 100644 (file)
@@ -436,6 +436,7 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c
        ast_cli(a->fd, "  -------------\n");
        ast_cli(a->fd, "  Manager (AMI):               %s\n", check_manager_enabled() ? "Enabled" : "Disabled");
        ast_cli(a->fd, "  Web Manager (AMI/HTTP):      %s\n", check_webmanager_enabled() ? "Enabled" : "Disabled");
+       ast_cli(a->fd, "  Send Manager FullyBooted:    %s\n", ast_opt_send_fullybooted ? "Enabled" : "Disabled");
        ast_cli(a->fd, "  Call data records:           %s\n", check_cdr_enabled() ? "Enabled" : "Disabled");
        ast_cli(a->fd, "  Realtime Architecture (ARA): %s\n", ast_realtime_enabled() ? "Enabled" : "Disabled");
 
@@ -2847,6 +2848,8 @@ static void ast_readconfig(void)
                                ast_eid_default = tmp_eid;
                        } else
                                ast_verbose("Invalid Entity ID '%s' provided\n", v->value);
+               } else if (!strcasecmp(v->name, "sendfullybooted")) {
+                       ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_SEND_FULLYBOOTED);
                }
        }
        for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) {
@@ -3504,6 +3507,9 @@ int main(int argc, char *argv[])
                sig_alert_pipe[0] = sig_alert_pipe[1] = -1;
 
        ast_set_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED);
+       if (ast_opt_send_fullybooted) {
+               manager_event(EVENT_FLAG_SYSTEM, "FullyBooted", "Status: Fully Booted\r\n");
+       }
 
        ast_process_pending_reloads();
 
index f7566d47f338d27e31ca9e8b115770e5c7af9e34..1604770f4fc14118cc899e98f5af1b6549fc0a7d 100644 (file)
@@ -1753,6 +1753,9 @@ static int action_login(struct mansession *s, const struct message *m)
                ast_verb(2, "%sManager '%s' logged on from %s\n", (s->session->managerid ? "HTTP " : ""), s->session->username, ast_inet_ntoa(s->session->sin.sin_addr));
        ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->session->managerid ? "HTTP " : ""), s->session->username, ast_inet_ntoa(s->session->sin.sin_addr));
        astman_send_ack(s, m, "Authentication accepted");
+       if (ast_opt_send_fullybooted && ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
+               manager_event(EVENT_FLAG_SYSTEM, "FullyBooted", "Status: Fully Booted\r\n");
+       }
        return 0;
 }