From 3f803ab3e89cbbe0a6f9bc80f835386be2df3e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 28 Mar 2018 09:16:48 +0300 Subject: [PATCH] MXS-1503: Don't use empty smart pointers The check for the existence of a valid pointer is now done in the correct place. --- .../readwritesplit/rwsplit_route_stmt.cc | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 13e2da807..491bd4c33 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -460,22 +460,29 @@ SRWBackend get_target_backend(RWSplitSession *rses, backend_type_t btype, /** get root master from available servers */ SRWBackend master = get_root_master(rses->backends); - if (master && master->in_use()) + if (master) { - if (master->is_master()) + if (master->in_use()) { - rval = master; + if (master->is_master()) + { + rval = master; + } + else + { + MXS_ERROR("Server '%s' does not have the master state and " + "can't be chosen as the master.", master->name()); + } } else { - MXS_ERROR("Server '%s' does not have the master state and " - "can't be chosen as the master.", master->name()); + MXS_ERROR("Server '%s' is not in use and can't be chosen as the master.", + master->name()); } } else { - MXS_ERROR("Server '%s' is not in use and can't be chosen as the master.", - master->name()); + MXS_ERROR("No master server available at this time."); } }