]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 265320,265467 via svnmerge from
authorTerry Wilson <twilson@digium.com>
Tue, 25 May 2010 13:33:21 +0000 (13:33 +0000)
committerTerry Wilson <twilson@digium.com>
Tue, 25 May 2010 13:33:21 +0000 (13:33 +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.4@265570 65c4cc65-6c06-0410-ace0-fbb531ad65f3

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

index 61237a2e1f04c6235a5928922084c994f7c4a83e..021eb80418eb73e881a90b71302e3a0eab2d05f8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -624,6 +624,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 ";dahdichanname = yes ; Channels created by chan_dahdi will be called 'DAHDI', otherwise 'Zap'" ; \
index a0a832c8da73c2b5931d404ed77a0775ac66c9ed..b6cc6f35b5791c1829c30ff16ff10d1bea2cd9f4 100644 (file)
@@ -122,6 +122,23 @@ Parameters: Channel, Timeout
 You can always get more information about a manager command
 with the "show manager command <command>" CLI command in Asterisk.
 
+Determining when all modules have finished loading
+--------------------------------------------------
+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
+
+
 Examples
 --------
 Login - Log a user into the manager interface.
index c3300660626ec5f3a0f29aae2cca5bf5ef08bf89..80376e6d21356388c9a37fdb07537cf13445698b 100644 (file)
@@ -83,6 +83,8 @@ enum ast_option_flags {
        AST_OPT_FLAG_MUTE = (1 << 22),
        /*! Generic PLC */
        AST_OPT_FLAG_GENERIC_PLC = (1 << 23),
+       /*! Send the FullyBooted AMI event when all modules are loaded */
+       AST_OPT_FLAG_SEND_FULLYBOOTED = (1 << 24),
 };
 
 /*! These are the options that set by default when Asterisk starts */
@@ -116,6 +118,7 @@ enum ast_option_flags {
 #define ast_opt_always_fork            ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
 #define ast_opt_mute                   ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)
 #define ast_opt_generic_plc         ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC)
+#define ast_opt_send_fullybooted       ast_test_flag(&ast_options, AST_OPT_FLAG_SEND_FULLYBOOTED)
 
 extern struct ast_flags ast_options;
 
index 14dbd9a38e2c7ccfc65fce5c184fdff6dbb7e2d9..bdf9d5c39c2e38d92224dca75c9b53b4f087c066 100644 (file)
@@ -2666,6 +2666,8 @@ static void ast_readconfig(void)
                                _dahdi_chan_mode = CHAN_ZAP_MODE;
                        }
 #endif
+               } else if (!strcasecmp(v->name, "sendfullybooted")) {
+                       ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_SEND_FULLYBOOTED);
                }
        }
        ast_config_destroy(cfg);
@@ -3192,6 +3194,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 bf19199c08b98558ac448bd30df871e7c37aaefe..fec3dc0706fef5ee957c85585cbb727ca0e72c36 100644 (file)
@@ -2300,6 +2300,9 @@ static int process_message(struct mansession *s, const struct message *m)
                                ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", 
                                        (s->session->sessiontimeout ? "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");
+                               }
                        }
                } else if (!strcasecmp(action, "Logoff")) {
                        astman_send_ack(s, m, "See ya");