Skip to content

Commit 76dde0e

Browse files
committed
DRY
1 parent 18820d1 commit 76dde0e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

ext/mysql2/client.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static void *nogvl_close(void *ptr) {
212212
mysql_client_wrapper *wrapper;
213213
wrapper = ptr;
214214
if (wrapper->connected) {
215-
wrapper->active_thread = Qnil;
215+
MARK_CONN_INACTIVE(self);
216216
wrapper->connected = 0;
217217
#ifndef _WIN32
218218
/* Invalidate the socket before calling mysql_close(). This prevents
@@ -256,7 +256,7 @@ static VALUE allocate(VALUE klass) {
256256
mysql_client_wrapper * wrapper;
257257
obj = Data_Make_Struct(klass, mysql_client_wrapper, rb_mysql_client_mark, rb_mysql_client_free, wrapper);
258258
wrapper->encoding = Qnil;
259-
wrapper->active_thread = Qnil;
259+
MARK_CONN_INACTIVE(self);
260260
wrapper->server_version = 0;
261261
wrapper->reconnect_enabled = 0;
262262
wrapper->connect_timeout = 0;
@@ -412,7 +412,7 @@ static VALUE do_send_query(void *args) {
412412
mysql_client_wrapper *wrapper = query_args->wrapper;
413413
if ((VALUE)rb_thread_call_without_gvl(nogvl_send_query, args, RUBY_UBF_IO, 0) == Qfalse) {
414414
/* an error occurred, we're not active anymore */
415-
wrapper->active_thread = Qnil;
415+
MARK_CONN_INACTIVE(self);
416416
return rb_raise_mysql2_error(wrapper);
417417
}
418418
return Qnil;
@@ -443,7 +443,7 @@ static void *nogvl_do_result(void *ptr, char use_result) {
443443

444444
/* once our result is stored off, this connection is
445445
ready for another command to be issued */
446-
wrapper->active_thread = Qnil;
446+
MARK_CONN_INACTIVE(self);
447447

448448
return result;
449449
}
@@ -512,7 +512,7 @@ struct async_query_args {
512512
static VALUE disconnect_and_raise(VALUE self, VALUE error) {
513513
GET_CLIENT(self);
514514

515-
wrapper->active_thread = Qnil;
515+
MARK_CONN_INACTIVE(self);
516516
wrapper->connected = 0;
517517

518518
/* 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-
wrapper->active_thread = Qnil;
591+
MARK_CONN_INACTIVE(self);
592592
}
593593

594594
return Qnil;

ext/mysql2/client.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ typedef struct {
5959
void rb_mysql_client_set_active_thread(VALUE self);
6060

6161
#define MARK_CONN_INACTIVE(conn) do {\
62-
GET_CLIENT(conn); \
6362
wrapper->active_thread = Qnil; \
6463
} while(0)
6564

0 commit comments

Comments
 (0)