Check if connection is valid in sb_lua_db_disconnect().

This commit is contained in:
Alexey Kopytov
2008-11-06 10:55:53 +00:00
parent d760f42b3d
commit 080ebfe37a
2 changed files with 3 additions and 2 deletions

View File

@ -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);

View File

@ -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;