summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Erickson <michae2@mariadb.com>2020-03-02 11:50:18 -0800
committerSergei Petrunia <psergey@askmonty.org>2020-03-10 11:22:33 +0300
commite5e812698d773a038ebb87b7dbd30dc6b6745a65 (patch)
treee893f420de2fa08b48a5fc559f234fcab0bd67ee
parentbcc0148b361c6bf5b5442dafe9ad21b52b4dd848 (diff)
downloadmariadb-git-e5e812698d773a038ebb87b7dbd30dc6b6745a65.tar.gz
hardcode xpand protocol to tcp
Hardcode MYSQL_OPT_PROTOCOL to TCP in the Xpand connection. We can add support for sockets later. Also fix a memory leak in xpand_hosts global variable.
-rw-r--r--storage/xpand/ha_xpand.cc14
-rw-r--r--storage/xpand/xpand_connection.cc2
2 files changed, 11 insertions, 5 deletions
diff --git a/storage/xpand/ha_xpand.cc b/storage/xpand/ha_xpand.cc
index 880fc12b6bf..58b13a50314 100644
--- a/storage/xpand/ha_xpand.cc
+++ b/storage/xpand/ha_xpand.cc
@@ -80,27 +80,29 @@ xpand_host_list *xpand_hosts;
static int check_hosts(MYSQL_THD thd, struct st_mysql_sys_var *var,
void *save, struct st_mysql_value *value)
{
+ DBUG_ENTER("check_hosts");
char b;
int len = 0;
const char *val = value->val_str(value, &b, &len);
if (!val)
- return HA_ERR_OUT_OF_MEM;
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
xpand_host_list list;
memset(&list, 0, sizeof(list));
int error_code = 0;
if ((error_code = list.fill(val)))
- return error_code;
+ DBUG_RETURN(error_code);
list.empty();
*static_cast<const char **>(save) = val;
- return 0;
+ DBUG_RETURN(0);
}
static void update_hosts(MYSQL_THD thd, struct st_mysql_sys_var *var,
void *var_ptr, const void *save)
{
+ DBUG_ENTER("update_hosts");
const char *from_save = *static_cast<const char * const *>(save);
mysql_rwlock_wrlock(&xpand_hosts_lock);
@@ -111,7 +113,7 @@ static void update_hosts(MYSQL_THD thd, struct st_mysql_sys_var *var,
if (error_code) {
my_free(list);
my_printf_error(error_code, "Unhandled error setting xpand hostlist", MYF(0));
- return;
+ DBUG_VOID_RETURN;
}
xpand_hosts->empty();
@@ -123,6 +125,7 @@ static void update_hosts(MYSQL_THD thd, struct st_mysql_sys_var *var,
*display_var = my_strdup(from_save, MYF(MY_WME));
mysql_rwlock_unlock(&xpand_hosts_lock);
+ DBUG_VOID_RETURN;
}
static char *xpand_hosts_str;
@@ -132,7 +135,7 @@ static MYSQL_SYSVAR_STR
xpand_hosts_str,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC,
"List of xpand hostnames seperated by commas, semicolons or spaces",
- check_hosts, update_hosts, "localhost"
+ check_hosts, update_hosts, "127.0.0.1"
);
char *xpand_username;
@@ -1496,6 +1499,7 @@ static int xpand_deinit(void *p)
DBUG_ENTER("xpand_deinit");
mysql_rwlock_wrlock(&xpand_hosts_lock);
xpand_hosts->empty();
+ my_free(xpand_hosts);
xpand_hosts = NULL;
mysql_rwlock_destroy(&xpand_hosts_lock);
DBUG_RETURN(0);
diff --git a/storage/xpand/xpand_connection.cc b/storage/xpand/xpand_connection.cc
index f9a38432db4..c06bdd0773e 100644
--- a/storage/xpand/xpand_connection.cc
+++ b/storage/xpand/xpand_connection.cc
@@ -165,6 +165,8 @@ int xpand_connection::connect_direct(char *host)
if (!mysql_init(&xpand_net))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ uint protocol_tcp = MYSQL_PROTOCOL_TCP;
+ mysql_options(&xpand_net, MYSQL_OPT_PROTOCOL, &protocol_tcp);
mysql_options(&xpand_net, MYSQL_OPT_READ_TIMEOUT,
&xpand_read_timeout);
mysql_options(&xpand_net, MYSQL_OPT_WRITE_TIMEOUT,