Skip to content

Commit edf08ac

Browse files
committed
MARK_CONN_INACTIVE is not needed
Simply we can use `wrapper->active_thread = Qnil;`.
1 parent c07feb8 commit edf08ac

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

ext/mysql2/client.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static VALUE allocate(VALUE klass) {
259259
mysql_client_wrapper * wrapper;
260260
obj = Data_Make_Struct(klass, mysql_client_wrapper, rb_mysql_client_mark, rb_mysql_client_free, wrapper);
261261
wrapper->encoding = Qnil;
262-
MARK_CONN_INACTIVE(wrapper);
262+
wrapper->active_thread = Qnil;
263263
wrapper->automatic_close = 1;
264264
wrapper->server_version = 0;
265265
wrapper->reconnect_enabled = 0;
@@ -418,7 +418,7 @@ static VALUE do_send_query(void *args) {
418418
mysql_client_wrapper *wrapper = query_args->wrapper;
419419
if ((VALUE)rb_thread_call_without_gvl(nogvl_send_query, args, RUBY_UBF_IO, 0) == Qfalse) {
420420
/* an error occurred, we're not active anymore */
421-
MARK_CONN_INACTIVE(wrapper);
421+
wrapper->active_thread = Qnil;
422422
return rb_raise_mysql2_error(wrapper);
423423
}
424424
return Qnil;
@@ -448,7 +448,7 @@ static void *nogvl_do_result(void *ptr, char use_result) {
448448

449449
/* once our result is stored off, this connection is
450450
ready for another command to be issued */
451-
MARK_CONN_INACTIVE(wrapper);
451+
wrapper->active_thread = Qnil;
452452

453453
return result;
454454
}
@@ -480,7 +480,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
480480
REQUIRE_CONNECTED(wrapper);
481481
if ((VALUE)rb_thread_call_without_gvl(nogvl_read_query_result, wrapper->client, RUBY_UBF_IO, 0) == Qfalse) {
482482
/* an error occurred, mark this connection inactive */
483-
MARK_CONN_INACTIVE(wrapper);
483+
wrapper->active_thread = Qnil;
484484
return rb_raise_mysql2_error(wrapper);
485485
}
486486

@@ -493,7 +493,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
493493

494494
if (result == NULL) {
495495
if (mysql_errno(wrapper->client) != 0) {
496-
MARK_CONN_INACTIVE(wrapper);
496+
wrapper->active_thread = Qnil;
497497
rb_raise_mysql2_error(wrapper);
498498
}
499499
/* no data and no error, so query was not a SELECT */
@@ -517,7 +517,7 @@ struct async_query_args {
517517
static VALUE disconnect_and_raise(VALUE self, VALUE error) {
518518
GET_CLIENT(self);
519519

520-
MARK_CONN_INACTIVE(wrapper);
520+
wrapper->active_thread = Qnil;
521521
wrapper->connected = 0;
522522

523523
/* Invalidate the MySQL socket to prevent further communication.
@@ -588,7 +588,7 @@ static VALUE finish_and_mark_inactive(void *args) {
588588
result = (MYSQL_RES *)rb_thread_call_without_gvl(nogvl_store_result, wrapper, RUBY_UBF_IO, 0);
589589
mysql_free_result(result);
590590

591-
MARK_CONN_INACTIVE(wrapper);
591+
wrapper->active_thread = Qnil;
592592
}
593593

594594
return Qnil;

ext/mysql2/client.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ typedef struct {
5959

6060
void rb_mysql_client_set_active_thread(VALUE self);
6161

62-
#define MARK_CONN_INACTIVE(wrapper) \
63-
wrapper->active_thread = Qnil;
64-
6562
#define GET_CLIENT(self) \
6663
mysql_client_wrapper *wrapper; \
6764
Data_Get_Struct(self, mysql_client_wrapper, wrapper);

ext/mysql2/statement.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
366366
if (metadata == NULL) {
367367
if (mysql_stmt_errno(stmt) != 0) {
368368
// either CR_OUT_OF_MEMORY or CR_UNKNOWN_ERROR. both fatal.
369-
MARK_CONN_INACTIVE(wrapper);
369+
wrapper->active_thread = Qnil;
370370
rb_raise_mysql2_stmt_error(stmt_wrapper);
371371
}
372372
// no data and no error, so query was not a SELECT
@@ -384,7 +384,7 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
384384
mysql_free_result(metadata);
385385
rb_raise_mysql2_stmt_error(stmt_wrapper);
386386
}
387-
MARK_CONN_INACTIVE(wrapper);
387+
wrapper->active_thread = Qnil;
388388
}
389389

390390
resultObj = rb_mysql_result_to_obj(stmt_wrapper->client, wrapper->encoding, current, metadata, self);

0 commit comments

Comments
 (0)