Skip to content

Commit

Permalink
src: disable raise in cfg
Browse files Browse the repository at this point in the history
NO_CHANGELOG=internal
NO_DOC=internal
NO_TEST=internal

Needed for tarantool#6128
  • Loading branch information
ligurio committed Nov 3, 2022
1 parent 63cd599 commit 43da892
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/cfg.c
Expand Up @@ -36,12 +36,42 @@

enum { MAX_OPT_NAME_LEN = 256, MAX_OPT_VAL_LEN = 256 };

/*
* @brief Toggle panics in cfg_get().
*/
static int cfg_panic;

/*
* @brief Enables panics in cfg_get().
*/
void
cfg_enable_panic(void)
{
cfg_panic = 1;
}

/*
* @brief Disables panics in cfg_get().
*/
void
cfg_disable_panic(void)
{
cfg_panic = 0;
}

static void
cfg_get(const char *param)
{
/* int panic = 1; */
/* va_list args; */
/* va_start(args, param); */
/* panic = va_arg(args, int); */
/* printf("cfg_get background %d\n", panic); */
/* va_end(args); */

const char *buf =
tt_snprintf(MAX_OPT_NAME_LEN, "return box.cfg.%s", param);
if (luaL_dostring(tarantool_L, buf) != 0)
if ((luaL_dostring(tarantool_L, buf) != 0) && cfg_panic)
panic("cfg_get('%s')", param);
}

Expand Down Expand Up @@ -76,6 +106,14 @@ cfg_isnumber(const char *param)
return ret;
}

/*
* @brief Returns a value of a boolean parameter whose name is passed.
*
* @param param - name of a boolean parameter
* @return -1 - undefined
* 1 - false or nil
* 0 - true
*/
int
cfg_getb(const char *param)
{
Expand Down
12 changes: 12 additions & 0 deletions src/cfg.h
Expand Up @@ -39,6 +39,18 @@ struct uri_set;
extern "C" {
#endif /* defined(__cplusplus) */

/*
* @brief Enables panics in cfg_get().
*/
void
cfg_enable_panic(void);

/*
* @brief Disables panics in cfg_get().
*/
void
cfg_disable_panic(void);

/**
* Fill @a uri_set according to cfg @a param.
* Return 0 if success, otherwise return -1
Expand Down

0 comments on commit 43da892

Please sign in to comment.