Skip to content

Commit 2481815

Browse files
committed
mark the connection inactive as soon as we possibly can
1 parent f00247f commit 2481815

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

ext/mysql2/client.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,17 @@ static VALUE nogvl_read_query_result(void *ptr) {
263263

264264
/* mysql_store_result may (unlikely) read rows off the socket */
265265
static VALUE nogvl_store_result(void *ptr) {
266-
MYSQL * client = ptr;
267-
return (VALUE)mysql_store_result(client);
266+
mysql_client_wrapper *wrapper;
267+
MYSQL_RES *result;
268+
269+
wrapper = (mysql_client_wrapper *)ptr;
270+
result = mysql_store_result(wrapper->client);
271+
272+
// once our result is stored off, this connection is
273+
// ready for another command to be issued
274+
wrapper->active = 0;
275+
276+
return (VALUE)result;
268277
}
269278

270279
static VALUE rb_mysql_client_async_result(VALUE self) {
@@ -286,10 +295,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
286295
return rb_raise_mysql2_error(wrapper);
287296
}
288297

289-
result = (MYSQL_RES *)rb_thread_blocking_region(nogvl_store_result, wrapper->client, RUBY_UBF_IO, 0);
290-
291-
// we have our result, mark this connection inactive
292-
MARK_CONN_INACTIVE(self);
298+
result = (MYSQL_RES *)rb_thread_blocking_region(nogvl_store_result, wrapper, RUBY_UBF_IO, 0);
293299

294300
if (result == NULL) {
295301
if (mysql_field_count(wrapper->client) != 0) {

0 commit comments

Comments
 (0)