options: Change ast_options from ast_flags to ast_flags64.

DeveloperNote: The 32-bit ast_options has no room left to accomodate new
options and so has been converted to an ast_flags64 structure. All internal
references to ast_options have been updated to use the 64-bit flag
manipulation macros.  External module references to the 32-bit ast_options
should continue to work on little-endian systems because the
least-significant bytes of a 64 bit integer will be in the same location as a
32-bit integer.  Because that's not the case on big-endian systems, we've
swapped the bytes in the flags manupulation macros on big-endian systems
so external modules should still work however you are encouraged to test.

(cherry picked from commit 709be42bc3)
releases/22
George Joseph 3 months ago
parent 5bdc661745
commit 9eef99f8f3

@ -101,42 +101,51 @@ enum ast_option_flags {
AST_OPT_FLAG_GENERIC_PLC = (1 << 30),
/*! Generic PLC onm equal codecs */
AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS = (1 << 31),
/*!
* ast_options is now an ast_flags64 structure so if you add more
* options, make sure to use (1ULL << <bits>) to ensure that the
* enum itself is allocated as a uint64_t instead of the default
* uint32_t. Attmpting to simply shift a 1 by more than 31 bits
* will result in a "shift-count-overflow" compile failure.
* Example:
* AST_OPT_FLAG_NEW_OPTION = (1ULL << 32),
*/
};
/*! These are the options that set by default when Asterisk starts */
#define AST_DEFAULT_OPTIONS (AST_OPT_FLAG_TRANSCODE_VIA_SLIN | AST_OPT_FLAG_CACHE_MEDIA_FRAMES)
#define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
#define ast_opt_no_fork ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)
#define ast_opt_quiet ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)
#define ast_opt_console ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)
#define ast_opt_high_priority ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
#define ast_opt_init_keys ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)
#define ast_opt_remote ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)
#define ast_opt_exec ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)
#define ast_opt_no_color ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)
#define ast_fully_booted ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
#define ast_opt_transcode_via_slin ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
#define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)
#define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
#define ast_opt_cache_media_frames ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_MEDIA_FRAMES)
#define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)
#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
#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_dbg_module ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_MODULE)
#define ast_opt_trace_module ast_test_flag(&ast_options, AST_OPT_FLAG_TRACE_MODULE)
#define ast_opt_light_background ast_test_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND)
#define ast_opt_force_black_background ast_test_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND)
#define ast_opt_hide_connect ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT)
#define ast_opt_lock_confdir ast_test_flag(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR)
#define ast_opt_generic_plc ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC)
#define ast_opt_ref_debug ast_test_flag(&ast_options, AST_OPT_FLAG_REF_DEBUG)
#define ast_opt_generic_plc_on_equal_codecs ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)
#define ast_opt_hide_messaging_ami_events ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS)
#define ast_opt_sounds_search_custom ast_test_flag(&ast_options, AST_OPT_FLAG_SOUNDS_SEARCH_CUSTOM)
#define ast_opt_exec_includes ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
#define ast_opt_no_fork ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_FORK)
#define ast_opt_quiet ast_test_flag64(&ast_options, AST_OPT_FLAG_QUIET)
#define ast_opt_console ast_test_flag64(&ast_options, AST_OPT_FLAG_CONSOLE)
#define ast_opt_high_priority ast_test_flag64(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
#define ast_opt_init_keys ast_test_flag64(&ast_options, AST_OPT_FLAG_INIT_KEYS)
#define ast_opt_remote ast_test_flag64(&ast_options, AST_OPT_FLAG_REMOTE)
#define ast_opt_exec ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC)
#define ast_opt_no_color ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_COLOR)
#define ast_fully_booted ast_test_flag64(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
#define ast_opt_transcode_via_slin ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
#define ast_opt_dump_core ast_test_flag64(&ast_options, AST_OPT_FLAG_DUMP_CORE)
#define ast_opt_cache_record_files ast_test_flag64(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
#define ast_opt_cache_media_frames ast_test_flag64(&ast_options, AST_OPT_FLAG_CACHE_MEDIA_FRAMES)
#define ast_opt_timestamp ast_test_flag64(&ast_options, AST_OPT_FLAG_TIMESTAMP)
#define ast_opt_reconnect ast_test_flag64(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_transmit_silence ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_opt_dont_warn ast_test_flag64(&ast_options, AST_OPT_FLAG_DONT_WARN)
#define ast_opt_always_fork ast_test_flag64(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
#define ast_opt_mute ast_test_flag64(&ast_options, AST_OPT_FLAG_MUTE)
#define ast_opt_dbg_module ast_test_flag64(&ast_options, AST_OPT_FLAG_DEBUG_MODULE)
#define ast_opt_trace_module ast_test_flag64(&ast_options, AST_OPT_FLAG_TRACE_MODULE)
#define ast_opt_light_background ast_test_flag64(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND)
#define ast_opt_force_black_background ast_test_flag64(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND)
#define ast_opt_hide_connect ast_test_flag64(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT)
#define ast_opt_lock_confdir ast_test_flag64(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR)
#define ast_opt_generic_plc ast_test_flag64(&ast_options, AST_OPT_FLAG_GENERIC_PLC)
#define ast_opt_ref_debug ast_test_flag64(&ast_options, AST_OPT_FLAG_REF_DEBUG)
#define ast_opt_generic_plc_on_equal_codecs ast_test_flag64(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)
#define ast_opt_hide_messaging_ami_events ast_test_flag64(&ast_options, AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS)
#define ast_opt_sounds_search_custom ast_test_flag64(&ast_options, AST_OPT_FLAG_SOUNDS_SEARCH_CUSTOM)
/*! Maximum log level defined by PJPROJECT. */
#define MAX_PJ_LOG_MAX_LEVEL 6
@ -184,7 +193,7 @@ extern int ast_option_pjproject_cache_pools;
/*! Current pjproject logging level */
extern int ast_option_pjproject_log_level;
extern struct ast_flags ast_options;
extern struct ast_flags64 ast_options;
extern int option_verbose;
extern int ast_option_maxfiles; /*!< Max number of open file handles (files, sockets) */

@ -110,10 +110,27 @@ extern unsigned int __unsigned_int_flags_dummy;
} while (0)
/* The following 64-bit flag code can most likely be erased after app_dial
is reorganized to either reduce the large number of options, or handle
them in some other way. At the time of this writing, app_dial would be
the only user of 64-bit option flags */
/*!
* \brief Swap the upper and lower 32 bits of a big-endian 64-bit integer
*
* This macro is needed to preserve ABI compatability on big-endian systems
* after changing from a 32 bit flags to a 64 bit flags. It ensures that a
* new 64-bit flag field will still work with a function that expects a
* 32-bit flag field. On a little-endian system, nothing is needed, since
* the 64-bit flags are already in the correct order.
*
* \note This macro is different than a standard byte swap, as it
* doesn't reverse the byte order, it just swaps the upper 4 bytes with
* the lower 4 bytes.
*
* \param flags The 64-bit flags to swap
* \retval The flags with the upper and lower 32 bits swapped if the system is big-endian,
*/
#if __BYTE_ORDER == __BIG_ENDIAN
#define SWAP64_32(flags) (((uint64_t)flags << 32) | ((uint64_t)flags >> 32))
#else
#define SWAP64_32(flags) (flags)
#endif
extern uint64_t __unsigned_int_flags_dummy64;
@ -121,21 +138,21 @@ extern uint64_t __unsigned_int_flags_dummy64;
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags & (flag)); \
((p)->flags & SWAP64_32(flag)); \
})
#define ast_set_flag64(p,flag) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags |= (flag)); \
((p)->flags |= SWAP64_32(flag)); \
} while(0)
#define ast_clear_flag64(p,flag) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags &= ~(flag)); \
((p)->flags &= ~SWAP64_32(flag)); \
} while(0)
#define ast_copy_flags64(dest,src,flagz) do { \
@ -144,8 +161,8 @@ extern uint64_t __unsigned_int_flags_dummy64;
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__d == &__x); \
(void) (&__s == &__x); \
(dest)->flags &= ~(flagz); \
(dest)->flags |= ((src)->flags & (flagz)); \
(dest)->flags &= ~SWAP64_32(flagz); \
(dest)->flags |= ((src)->flags & SWAP64_32(flagz)); \
} while (0)
#define ast_set2_flag64(p,value,flag) do { \
@ -153,19 +170,20 @@ extern uint64_t __unsigned_int_flags_dummy64;
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
if (value) \
(p)->flags |= (flag); \
(p)->flags |= SWAP64_32(flag); \
else \
(p)->flags &= ~(flag); \
(p)->flags &= ~SWAP64_32(flag); \
} while (0)
#define ast_set_flags_to64(p,flag,value) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
(p)->flags &= ~(flag); \
(p)->flags |= (value); \
(p)->flags &= ~SWAP64_32(flag); \
(p)->flags |= SWAP64_32(value); \
} while (0)
#define AST_FLAGS64_ALL ULONG_MAX
/* Non-type checking variations for non-unsigned int flags. You
should only use non-unsigned int flags where required by

@ -554,11 +554,11 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c
ast_cli(a->fd, " Running directory: %s\n", dir);
}
#endif /* defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS) */
ast_cli(a->fd, " Executable includes: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES) ? "Enabled" : "Disabled");
ast_cli(a->fd, " Transcode via SLIN: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) ? "Enabled" : "Disabled");
ast_cli(a->fd, " Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled");
ast_cli(a->fd, " Generic PLC: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) ? "Enabled" : "Disabled");
ast_cli(a->fd, " Generic PLC on equal codecs: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS) ? "Enabled" : "Disabled");
ast_cli(a->fd, " Executable includes: %s\n", ast_opt_exec_includes ? "Enabled" : "Disabled");
ast_cli(a->fd, " Transcode via SLIN: %s\n", ast_opt_transcode_via_slin ? "Enabled" : "Disabled");
ast_cli(a->fd, " Transmit silence during rec: %s\n", ast_opt_transmit_silence ? "Enabled" : "Disabled");
ast_cli(a->fd, " Generic PLC: %s\n", ast_opt_generic_plc ? "Enabled" : "Disabled");
ast_cli(a->fd, " Generic PLC on equal codecs: %s\n", ast_opt_generic_plc_on_equal_codecs ? "Enabled" : "Disabled");
ast_cli(a->fd, " Hide Msg Chan AMI events: %s\n", ast_opt_hide_messaging_ami_events ? "Enabled" : "Disabled");
ast_cli(a->fd, " Sounds search custom dir: %s\n", ast_opt_sounds_search_custom ? "Enabled" : "Disabled");
ast_cli(a->fd, " Min DTMF duration:: %u\n", option_dtmfminduration);
@ -3635,7 +3635,7 @@ int main(int argc, char *argv[])
/* if the progname is rasterisk consider it a remote console */
if (argv[0] && (strstr(argv[0], "rasterisk")) != NULL) {
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
ast_set_flag64(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
}
ast_mainpid = getpid();
@ -3643,7 +3643,7 @@ int main(int argc, char *argv[])
while ((c = getopt(argc, argv, getopt_settings)) != -1) {
switch (c) {
case 'X':
ast_set_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);
ast_set_flag64(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);
break;
case 'C':
set_asterisk_conf_path(optarg);
@ -3659,7 +3659,7 @@ int main(int argc, char *argv[])
case 'x':
/* ast_opt_remote is checked during config load. This is only part of what
* these options do, see the second loop for the rest of the actions. */
ast_set_flag(&ast_options, AST_OPT_FLAG_REMOTE);
ast_set_flag64(&ast_options, AST_OPT_FLAG_REMOTE);
break;
case 'V':
show_version();
@ -3691,8 +3691,8 @@ int main(int argc, char *argv[])
* option flags for new features. */
switch (c) {
case 'B': /* Force black background */
ast_set_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
ast_clear_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
ast_set_flag64(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
ast_clear_flag64(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
break;
case 'X':
/* The command-line -X option enables #exec for asterisk.conf only. */
@ -3701,7 +3701,7 @@ int main(int argc, char *argv[])
/* already processed. */
break;
case 'c':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
ast_set_flag64(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
break;
case 'd':
/* already processed. */
@ -3715,17 +3715,17 @@ int main(int argc, char *argv[])
#endif
#if HAVE_WORKING_FORK
case 'F':
ast_set_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
ast_set_flag64(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
break;
case 'f':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
ast_set_flag64(&ast_options, AST_OPT_FLAG_NO_FORK);
break;
#endif
case 'G':
rungroup = ast_strdup(optarg);
break;
case 'g':
ast_set_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE);
ast_set_flag64(&ast_options, AST_OPT_FLAG_DUMP_CORE);
break;
case 'h':
/* already processed. */
@ -3736,7 +3736,7 @@ int main(int argc, char *argv[])
" It will always be enabled if you have a timing module loaded.\n");
break;
case 'i':
ast_set_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS);
ast_set_flag64(&ast_options, AST_OPT_FLAG_INIT_KEYS);
break;
case 'L':
if ((sscanf(optarg, "%30lf", &ast_option_maxload) != 1) || (ast_option_maxload < 0.0)) {
@ -3749,22 +3749,22 @@ int main(int argc, char *argv[])
}
break;
case 'm':
ast_set_flag(&ast_options, AST_OPT_FLAG_MUTE);
ast_set_flag64(&ast_options, AST_OPT_FLAG_MUTE);
break;
case 'n':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_COLOR);
ast_set_flag64(&ast_options, AST_OPT_FLAG_NO_COLOR);
break;
case 'p':
ast_set_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY);
ast_set_flag64(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY);
break;
case 'q':
ast_set_flag(&ast_options, AST_OPT_FLAG_QUIET);
ast_set_flag64(&ast_options, AST_OPT_FLAG_QUIET);
break;
case 'R':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE | AST_OPT_FLAG_RECONNECT);
ast_set_flag64(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE | AST_OPT_FLAG_RECONNECT);
break;
case 'r':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
ast_set_flag64(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
break;
case 's':
if (ast_opt_remote) {
@ -3772,10 +3772,10 @@ int main(int argc, char *argv[])
}
break;
case 'T':
ast_set_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP);
ast_set_flag64(&ast_options, AST_OPT_FLAG_TIMESTAMP);
break;
case 't':
ast_set_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES);
ast_set_flag64(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES);
break;
case 'U':
runuser = ast_strdup(optarg);
@ -3785,14 +3785,14 @@ int main(int argc, char *argv[])
/* already processed. */
break;
case 'W': /* White background */
ast_set_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
ast_clear_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
ast_set_flag64(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
ast_clear_flag64(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
break;
case 'x':
/* -r is implied by -x so set the flags -r sets as well. */
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
ast_set_flag64(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
ast_set_flag(&ast_options, AST_OPT_FLAG_EXEC | AST_OPT_FLAG_NO_COLOR);
ast_set_flag64(&ast_options, AST_OPT_FLAG_EXEC | AST_OPT_FLAG_NO_COLOR);
xarg = ast_strdup(optarg);
break;
case '?':
@ -3868,7 +3868,7 @@ int main(int argc, char *argv[])
if (ast_opt_always_fork && (ast_opt_remote || ast_opt_console)) {
fprintf(stderr, "'alwaysfork' is not compatible with console or remote console mode; ignored\n");
ast_clear_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
ast_clear_flag64(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
}
if (ast_opt_dump_core) {
@ -3968,7 +3968,7 @@ int main(int argc, char *argv[])
}
}
if (runuser && !ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)) {
if (runuser && !ast_opt_remote) {
#ifdef HAVE_CAP
int has_cap = 1;
#endif /* HAVE_CAP */
@ -4153,9 +4153,9 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
/* Check whether high prio was successfully set by us or some
* other incantation. */
if (has_priority()) {
ast_set_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY);
ast_set_flag64(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY);
} else {
ast_clear_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY);
ast_clear_flag64(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY);
}
/* Spawning of astcanary must happen AFTER the call to daemon(3) */
@ -4356,7 +4356,7 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
ast_process_pending_reloads();
ast_set_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED);
ast_set_flag64(&ast_options, AST_OPT_FLAG_FULLY_BOOTED);
publish_fully_booted();
pthread_sigmask(SIG_UNBLOCK, &sigs, NULL);

@ -509,7 +509,7 @@ static char *handle_debug_or_trace(int handler, struct ast_cli_entry *e, int cmd
}
AST_RWLIST_REMOVE(modules, ml, entry);
if (AST_RWLIST_EMPTY(modules)) {
ast_clear_flag(&ast_options, module_option);
ast_clear_flag64(&ast_options, module_option);
}
AST_RWLIST_UNLOCK(modules);
ast_cli(a->fd, "Core %s was %u and has been set to 0 for '%s'.\n", handler_name,
@ -537,7 +537,7 @@ static char *handle_debug_or_trace(int handler, struct ast_cli_entry *e, int cmd
strcpy(ml->module, mod);
AST_RWLIST_INSERT_TAIL(modules, ml, entry);
}
ast_set_flag(&ast_options, module_option);
ast_set_flag64(&ast_options, module_option);
ast_cli(a->fd, "Core %s was %d and has been set to %u for '%s'.\n", handler_name,
oldval, ml->level, ml->module);
@ -555,7 +555,7 @@ static char *handle_debug_or_trace(int handler, struct ast_cli_entry *e, int cmd
while ((ml = AST_RWLIST_REMOVE_HEAD(modules, entry))) {
ast_free(ml);
}
ast_clear_flag(&ast_options, AST_OPT_FLAG_DEBUG_MODULE);
ast_clear_flag64(&ast_options, AST_OPT_FLAG_DEBUG_MODULE);
AST_RWLIST_UNLOCK(modules);
}
oldval = *core_option;
@ -1971,7 +1971,7 @@ static char *handle_cli_wait_fullybooted(struct ast_cli_entry *e, int cmd, struc
return NULL;
}
while (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
while (!ast_fully_booted) {
usleep(100);
}

@ -1546,7 +1546,7 @@ char *ast_module_helper(const char *line, const char *word, int pos, int state,
}
/* Tab completion can't be used during startup, or CLI and loader will deadlock. */
if (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
if (!ast_fully_booted) {
return NULL;
}

@ -3377,7 +3377,7 @@ static int action_login(struct mansession *s, const struct message *m)
astman_send_ack(s, m, "Authentication accepted");
if ((s->session->send_events & EVENT_FLAG_SYSTEM)
&& (s->session->readperm & EVENT_FLAG_SYSTEM)
&& ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
&& ast_fully_booted) {
struct ast_str *auth = ast_str_alloca(MAX_AUTH_PERM_STRING);
const char *cat_str = authority_to_str(EVENT_FLAG_SYSTEM, &auth);
long uptime = 0;

@ -59,7 +59,7 @@
*/
/*! @{ */
struct ast_flags ast_options = { AST_DEFAULT_OPTIONS };
struct ast_flags64 ast_options = { AST_DEFAULT_OPTIONS };
/*! Maximum active system verbosity level. */
int ast_verb_sys_level;
@ -229,7 +229,7 @@ void load_asterisk_conf(void)
#ifdef REF_DEBUG
/* The REF_DEBUG compiler flag is now only used to enable refdebug by default.
* Support for debugging reference counts is always compiled in. */
ast_set2_flag(&ast_options, 1, AST_OPT_FLAG_REF_DEBUG);
ast_set2_flag64(&ast_options, 1, AST_OPT_FLAG_REF_DEBUG);
#endif
ast_set_default_eid(&ast_eid_default);
@ -238,7 +238,7 @@ void load_asterisk_conf(void)
/* If AST_OPT_FLAG_EXEC_INCLUDES was previously enabled with -X turn it off now.
* Using #exec from other configs requires that it be enabled from asterisk.conf. */
ast_clear_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);
ast_clear_flag64(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);
/* no asterisk.conf? no problem, use buildtime config! */
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
@ -307,10 +307,10 @@ void load_asterisk_conf(void)
option_verbose_new = atoi(v->value);
/* whether or not to force timestamping in CLI verbose output. (-T at startup) */
} else if (!strcasecmp(v->name, "timestamp")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TIMESTAMP);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_TIMESTAMP);
/* whether or not to support #exec in config files */
} else if (!strcasecmp(v->name, "execincludes")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_EXEC_INCLUDES);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_EXEC_INCLUDES);
/* debug level (-d at startup) */
} else if (!strcasecmp(v->name, "debug")) {
option_debug_new = 0;
@ -323,55 +323,55 @@ void load_asterisk_conf(void)
option_trace_new = ast_true(v->value) ? 1 : 0;
}
} else if (!strcasecmp(v->name, "refdebug")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_REF_DEBUG);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_REF_DEBUG);
#if HAVE_WORKING_FORK
/* Disable forking (-f at startup) */
} else if (!strcasecmp(v->name, "nofork")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);
/* Always fork, even if verbose or debug are enabled (-F at startup) */
} else if (!strcasecmp(v->name, "alwaysfork")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK);
#endif
/* Run quietly (-q at startup ) */
} else if (!strcasecmp(v->name, "quiet")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
/* Run as console (-c at startup, implies nofork) */
} else if (!strcasecmp(v->name, "console")) {
if (!ast_opt_remote) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
}
/* Run with high priority if the O/S permits (-p at startup) */
} else if (!strcasecmp(v->name, "highpriority")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY);
/* Initialize RSA auth keys (IAX2) (-i at startup) */
} else if (!strcasecmp(v->name, "initcrypto")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INIT_KEYS);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_INIT_KEYS);
/* Disable ANSI colors for console (-c at startup) */
} else if (!strcasecmp(v->name, "nocolor")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_COLOR);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_COLOR);
/* Disable some usage warnings for picky people :p */
} else if (!strcasecmp(v->name, "dontwarn")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DONT_WARN);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_DONT_WARN);
/* Dump core in case of crash (-g) */
} else if (!strcasecmp(v->name, "dumpcore")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DUMP_CORE);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_DUMP_CORE);
/* Cache recorded sound files to another directory during recording */
} else if (!strcasecmp(v->name, "cache_record_files")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_RECORD_FILES);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_RECORD_FILES);
#if !defined(LOW_MEMORY)
/* Cache media frames for performance */
} else if (!strcasecmp(v->name, "cache_media_frames")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_MEDIA_FRAMES);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_MEDIA_FRAMES);
#endif
/* Specify cache directory */
} else if (!strcasecmp(v->name, "record_cache_dir")) {
ast_copy_string(record_cache_dir, v->value, AST_CACHE_DIR_LEN);
/* Build transcode paths via SLINEAR, instead of directly */
} else if (!strcasecmp(v->name, "transcode_via_sln")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSCODE_VIA_SLIN);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSCODE_VIA_SLIN);
/* Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated on a channel */
} else if (!strcasecmp(v->name, "transmit_silence_during_record") || !strcasecmp(v->name, "transmit_silence")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSMIT_SILENCE);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSMIT_SILENCE);
} else if (!strcasecmp(v->name, "mindtmfduration")) {
if (sscanf(v->value, "%30u", &option_dtmfminduration) != 1) {
option_dtmfminduration = AST_MIN_DTMF_DURATION;
@ -451,31 +451,31 @@ void load_asterisk_conf(void)
ast_log(LOG_WARNING, "Invalid Entity ID '%s' provided\n", v->value);
}
} else if (!strcasecmp(v->name, "lightbackground")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LIGHT_BACKGROUND);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_LIGHT_BACKGROUND);
} else if (!strcasecmp(v->name, "forceblackbackground")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
} else if (!strcasecmp(v->name, "hideconnect")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIDE_CONSOLE_CONNECT);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIDE_CONSOLE_CONNECT);
} else if (!strcasecmp(v->name, "lockconfdir")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LOCK_CONFIG_DIR);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_LOCK_CONFIG_DIR);
} else if (!strcasecmp(v->name, "stdexten")) {
/* Choose how to invoke the extensions.conf stdexten */
if (!strcasecmp(v->value, "gosub")) {
ast_clear_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);
ast_clear_flag64(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);
} else if (!strcasecmp(v->value, "macro")) {
ast_set_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);
ast_set_flag64(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);
} else {
ast_log(LOG_WARNING,
"'%s' is not a valid setting for the stdexten option, defaulting to 'gosub'\n",
v->value);
ast_clear_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);
ast_clear_flag64(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO);
}
} else if (!strcasecmp(v->name, "live_dangerously")) {
live_dangerously = ast_true(v->value);
} else if (!strcasecmp(v->name, "hide_messaging_ami_events")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS);
} else if (!strcasecmp(v->name, "sounds_search_custom_dir")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_SOUNDS_SEARCH_CUSTOM);
ast_set2_flag64(&ast_options, ast_true(v->value), AST_OPT_FLAG_SOUNDS_SEARCH_CUSTOM);
} else if (!strcasecmp(v->name, "channel_storage_backend")) {
internal_channel_set_current_storage_driver(v->value);
} else if (!strcasecmp(v->name, "disable_remote_console_shell")) {

@ -4735,7 +4735,7 @@ enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
return AST_PBX_FAILED;
}
if (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
if (!ast_fully_booted) {
ast_log(LOG_WARNING, "PBX requires Asterisk to be fully booted\n");
return AST_PBX_FAILED;
}
@ -4757,7 +4757,7 @@ enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args
{
enum ast_pbx_result res = AST_PBX_SUCCESS;
if (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
if (!ast_fully_booted) {
ast_log(LOG_WARNING, "PBX requires Asterisk to be fully booted\n");
return AST_PBX_FAILED;
}

@ -261,9 +261,9 @@ static int reload_module(void)
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC);
ast_set2_flag64(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC);
} else if (!strcasecmp(var->name, "genericplc_on_equal_codecs")) {
ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS);
ast_set2_flag64(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS);
}
}
ast_config_destroy(cfg);
@ -272,7 +272,7 @@ static int reload_module(void)
* Force on_equal_codecs to false if generic_plc is false.
*/
if (!ast_opt_generic_plc) {
ast_set2_flag(&ast_options, 0, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS);
ast_set2_flag64(&ast_options, 0, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS);
}
return 0;

@ -486,7 +486,7 @@ static pj_bool_t distributor(pjsip_rx_data *rdata)
struct ast_taskprocessor *serializer = NULL;
pjsip_rx_data *clone;
if (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
if (!ast_fully_booted) {
/*
* Ignore everything until we are fully booted. Let the
* peer retransmit messages until we are ready.

@ -1603,7 +1603,7 @@ static int load_module(void)
if (!ast_sip_get_mwi_disable_initial_unsolicited()) {
create_mwi_subscriptions();
if (ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
if (ast_fully_booted) {
ast_sip_push_task(ast_serializer_pool_get(mwi_serializer_pool),
send_initial_notify_all, NULL);
} else {

@ -6102,7 +6102,7 @@ static int load_module(void)
pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_ALLOW, NULL, 1, &str_PUBLISH);
if (ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
if (ast_fully_booted) {
ast_sip_push_task(NULL, subscription_persistence_load, NULL);
} else {
struct stasis_subscription *sub;

@ -1363,27 +1363,27 @@ enum ast_option_flags {
struct ast_flags ast_options = { AST_DEFAULT_OPTIONS };
#define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
#define ast_opt_no_fork ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)
#define ast_opt_quiet ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)
#define ast_opt_console ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)
#define ast_opt_high_priority ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
#define ast_opt_init_keys ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)
#define ast_opt_remote ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)
#define ast_opt_exec ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)
#define ast_opt_no_color ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)
#define ast_fully_booted ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
#define ast_opt_transcode_via_slin ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
#define ast_opt_priority_jumping ast_test_flag(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)
#define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)
#define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
#define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)
#define ast_opt_override_config ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)
#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
#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_exec_includes ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
#define ast_opt_no_fork ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_FORK)
#define ast_opt_quiet ast_test_flag64(&ast_options, AST_OPT_FLAG_QUIET)
#define ast_opt_console ast_test_flag64(&ast_options, AST_OPT_FLAG_CONSOLE)
#define ast_opt_high_priority ast_test_flag64(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
#define ast_opt_init_keys ast_test_flag64(&ast_options, AST_OPT_FLAG_INIT_KEYS)
#define ast_opt_remote ast_test_flag64(&ast_options, AST_OPT_FLAG_REMOTE)
#define ast_opt_exec ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC)
#define ast_opt_no_color ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_COLOR)
#define ast_fully_booted ast_test_flag64(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
#define ast_opt_transcode_via_slin ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
#define ast_opt_priority_jumping ast_test_flag64(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)
#define ast_opt_dump_core ast_test_flag64(&ast_options, AST_OPT_FLAG_DUMP_CORE)
#define ast_opt_cache_record_files ast_test_flag64(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
#define ast_opt_timestamp ast_test_flag64(&ast_options, AST_OPT_FLAG_TIMESTAMP)
#define ast_opt_override_config ast_test_flag64(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)
#define ast_opt_reconnect ast_test_flag64(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_transmit_silence ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_opt_dont_warn ast_test_flag64(&ast_options, AST_OPT_FLAG_DONT_WARN)
#define ast_opt_always_fork ast_test_flag64(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
#define ast_opt_mute ast_test_flag64(&ast_options, AST_OPT_FLAG_MUTE)
extern int option_verbose;
extern int option_debug; /*!< Debugging */

Loading…
Cancel
Save