From 080ebfe37a3852cb99a6d6b01f355a32a89daf0e Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 6 Nov 2008 10:55:53 +0000 Subject: [PATCH] Check if connection is valid in sb_lua_db_disconnect(). --- sysbench/drivers/mysql/drv_mysql.c | 2 +- sysbench/scripting/script_lua.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sysbench/drivers/mysql/drv_mysql.c b/sysbench/drivers/mysql/drv_mysql.c index a7bc6f0..cda6662 100644 --- a/sysbench/drivers/mysql/drv_mysql.c +++ b/sysbench/drivers/mysql/drv_mysql.c @@ -271,6 +271,7 @@ int mysql_drv_connect(db_conn_t *sb_conn) return 1; sb_conn->ptr = con; + DEBUG("mysql_init(%p)", con); mysql_init(con); pthread_mutex_lock(&hosts_mutex); @@ -280,7 +281,6 @@ int mysql_drv_connect(db_conn_t *sb_conn) host = SB_LIST_ENTRY(hosts_pos, value_t, listitem)->data; pthread_mutex_unlock(&hosts_mutex); - DEBUG("mysql_init(%p)", con); mysql_options(con, MYSQL_READ_DEFAULT_GROUP, "sysbench"); DEBUG("mysql_options(%p, MYSQL_READ_DEFAULT_GROUP, \"sysbench\")", con); diff --git a/sysbench/scripting/script_lua.c b/sysbench/scripting/script_lua.c index b00d466..73e1a0e 100644 --- a/sysbench/scripting/script_lua.c +++ b/sysbench/scripting/script_lua.c @@ -579,7 +579,8 @@ int sb_lua_db_disconnect(lua_State *L) ctxt = sb_lua_get_context(L); - db_disconnect(ctxt->con); + if (ctxt->con) + db_disconnect(ctxt->con); ctxt->con = NULL;