diff --git a/ext/mysql2/client.c b/ext/mysql2/client.c index b63078288..2917bcfdd 100644 --- a/ext/mysql2/client.c +++ b/ext/mysql2/client.c @@ -323,9 +323,9 @@ static VALUE allocate(VALUE klass) { wrapper->server_version = 0; wrapper->reconnect_enabled = 0; wrapper->connect_timeout = 0; - wrapper->initialized = 0; /* means that that the wrapper is initialized */ + wrapper->initialized = 0; /* will be set true after calling mysql_init */ + wrapper->closed = 1; /* will be set false after calling mysql_real_connect */ wrapper->refcount = 1; - wrapper->closed = 0; wrapper->client = (MYSQL*)xmalloc(sizeof(MYSQL)); return obj; @@ -467,6 +467,7 @@ static VALUE rb_mysql_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VA rb_raise_mysql2_error(wrapper); } + wrapper->closed = 0; wrapper->server_version = mysql_get_server_version(wrapper->client); return self; }