From 555aa6d2c8fdc0db058dadddf1a4cb6520044b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 24 Oct 2017 08:43:38 +0300 Subject: [PATCH] Fix test crash in sync_slaves The crash happens if the slave is not configured for replication or the connection is broken when results are read. Adding missing return value checks will fix it. --- maxscale-system-test/mariadb_nodes.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/maxscale-system-test/mariadb_nodes.cpp b/maxscale-system-test/mariadb_nodes.cpp index 4b8dc3403..a8a530c4c 100644 --- a/maxscale-system-test/mariadb_nodes.cpp +++ b/maxscale-system-test/mariadb_nodes.cpp @@ -1270,6 +1270,7 @@ static void wait_until_pos(MYSQL *mysql, int filenum, int pos) { int slave_filenum = 0; int slave_pos = 0; + bool error = false; do { @@ -1284,17 +1285,23 @@ static void wait_until_pos(MYSQL *mysql, int filenum, int pos) if (res) { MYSQL_ROW row = mysql_fetch_row(res); + error = true; - if (row && row[6] && row[21]) + if (row && row[5] && row[21]) { - char *file_suffix = strchr(row[5], '.') + 1; - slave_filenum = atoi(file_suffix); - slave_pos = atoi(row[21]); + char *file_suffix = strchr(row[5], '.'); + if (file_suffix) + { + file_suffix++; + slave_filenum = atoi(file_suffix); + slave_pos = atoi(row[21]); + error = false; + } } mysql_free_result(res); } } - while (slave_filenum < filenum || slave_pos < pos); + while ((slave_filenum < filenum || slave_pos < pos) && !error); } void Mariadb_nodes::sync_slaves(int node)