summaryrefslogtreecommitdiff
path: root/include/asterisk/cli.h
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2016-03-10 16:58:49 -0600
committerMark Michelson <mmichelson@digium.com>2016-03-24 09:29:07 -0500
commit59c8e189fddcbc861947143f48e5b86e4707b29a (patch)
tree2d2ff9f7eec303cd4d65d78a807b640cf757c6ea /include/asterisk/cli.h
parented34bbdf9becaa61fa2ae544605426b6c6bbbb0f (diff)
Restrict CLI/AMI commands on shutdown.
During stress testing, we have frequently seen crashes occur because a CLI or AMI command attempts to access information that is in the process of being destroyed. When addressing how to fix this issue, we initially considered fixing individual crashes we observed. However, the changes required to fix those problems would introduce considerable overhead to the nominal case. This is not reasonable in order to prevent a crash from occurring while Asterisk is already shutting down. Instead, this change makes it so AMI and CLI commands cannot be executed if Asterisk is being shut down. For AMI, this is absolute. For CLI, though, certain commands can be registered so that they may be run during Asterisk shutdown. ASTERISK-25825 #close Change-Id: I8887e215ac352fadf7f4c1e082da9089b1421990
Diffstat (limited to 'include/asterisk/cli.h')
-rw-r--r--include/asterisk/cli.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h
index 458ebc8aa..c51d89eb8 100644
--- a/include/asterisk/cli.h
+++ b/include/asterisk/cli.h
@@ -310,6 +310,18 @@ char **ast_cli_completion_matches(const char *, const char *);
*/
char *ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos);
+/*!
+ * \brief Allow a CLI command to be executed while Asterisk is shutting down.
+ *
+ * CLI commands by defeault are disabled when Asterisk is shutting down. This is
+ * to ensure the safety of the shutdown since CLI commands may attempt to access
+ * resources that have been freed as a result of the shutdown.
+ *
+ * If a CLI command should be allowed at shutdown, then the best way to enable this
+ * is to call ast_cli_allow_at_shutdown during the CLI_INIT state of the CLI handler.
+ */
+int ast_cli_allow_at_shutdown(struct ast_cli_entry *e);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif