From d5c0c7c8698a557ff0895b4b0f23221b681fdc16 Mon Sep 17 00:00:00 2001 From: liuyanlei25 <15510772982@163.com> Date: Thu, 16 Aug 2018 17:27:36 +0800 Subject: [PATCH] change check-dns into T/F --- src/chassis-options-utils.c | 7 +++++-- src/mysql-proxy-cli.c | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/chassis-options-utils.c b/src/chassis-options-utils.c index 28e6b816..3c3af877 100644 --- a/src/chassis-options-utils.c +++ b/src/chassis-options-utils.c @@ -1450,8 +1450,11 @@ show_check_dns(gpointer param) { struct external_param *opt_param = (struct external_param *)param; chassis *srv = opt_param->chas; gint opt_type = opt_param->opt_type; - if (CAN_SHOW_OPTS_PROPERTY(opt_type) || CAN_SAVE_OPTS_PROPERTY(opt_type)) { - return g_strdup_printf("%d", srv->check_dns); + if (CAN_SHOW_OPTS_PROPERTY(opt_type)) { + return g_strdup_printf("%s", srv->check_dns ? "true" : "false"); + } + if (CAN_SAVE_OPTS_PROPERTY(opt_type)) { + return (srv->check_dns == 0) ? g_strdup("false") : NULL; } return NULL; } diff --git a/src/mysql-proxy-cli.c b/src/mysql-proxy-cli.c index 154878cc..3927b63a 100644 --- a/src/mysql-proxy-cli.c +++ b/src/mysql-proxy-cli.c @@ -158,7 +158,8 @@ struct chassis_frontend_t { gchar *sql_log_mode; guint sql_log_idletime; gint sql_log_maxnum; - gint check_dns; + + int check_dns; }; /** @@ -201,7 +202,9 @@ chassis_frontend_new(void) frontend->sql_log_mode = NULL; frontend->sql_log_idletime = 0; frontend->sql_log_maxnum = -1; + frontend->check_dns = 0; + return frontend; } @@ -537,8 +540,8 @@ chassis_frontend_set_chassis_options(struct chassis_frontend_t *frontend, chassi assign_sql_log_maxnum, show_sql_log_maxnum, ALL_OPTS_PROPERTY); chassis_options_add(opts, "check-dns", - 0, 0, OPTION_ARG_INT, &(frontend->check_dns), - "check dns when hostname changed","", + 0, 0, OPTION_ARG_NONE, &(frontend->check_dns), + "check dns when hostname changed",NULL, assign_check_dns, show_check_dns, ALL_OPTS_PROPERTY); return 0;