File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,7 @@ static void rb_mysql_client_free(void *ptr) {
199
199
200
200
wrapper -> refcount -- ;
201
201
if (wrapper -> refcount == 0 ) {
202
- nogvl_close (wrapper );
203
- xfree (wrapper -> client );
204
- xfree (wrapper );
202
+ close_connection_and_free_mysql2_client (wrapper );
205
203
}
206
204
}
207
205
@@ -1311,3 +1309,12 @@ void init_mysql2_client() {
1311
1309
LONG2NUM (CLIENT_BASIC_FLAGS ));
1312
1310
#endif
1313
1311
}
1312
+
1313
+ void close_connection_and_free_mysql2_client (void * ptr ) {
1314
+ mysql_client_wrapper * wrapper = (mysql_client_wrapper * )ptr ;
1315
+
1316
+ nogvl_close (wrapper );
1317
+ xfree (wrapper -> client );
1318
+ xfree (wrapper );
1319
+ }
1320
+
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ rb_thread_call_without_gvl(
37
37
#endif /* ! HAVE_RB_THREAD_CALL_WITHOUT_GVL */
38
38
39
39
void init_mysql2_client ();
40
+ void close_connection_and_free_mysql2_client (void * );
40
41
41
42
typedef struct {
42
43
VALUE encoding ;
Original file line number Diff line number Diff line change 1
1
#include <mysql2_ext.h>
2
2
#include <stdint.h>
3
3
4
+ #include "client.h"
4
5
#include "mysql_enc_to_ruby.h"
5
6
6
7
#ifdef HAVE_RUBY_ENCODING_H
@@ -86,8 +87,7 @@ static void rb_mysql_result_free(void *ptr) {
86
87
if (wrapper -> client != Qnil ) {
87
88
wrapper -> client_wrapper -> refcount -- ;
88
89
if (wrapper -> client_wrapper -> refcount == 0 ) {
89
- xfree (wrapper -> client_wrapper -> client );
90
- xfree (wrapper -> client_wrapper );
90
+ close_connection_and_free_mysql2_client (wrapper -> client_wrapper );
91
91
}
92
92
}
93
93
You can’t perform that action at this time.
0 commit comments