@@ -57,7 +57,7 @@ static VALUE rb_hash_dup(VALUE other) {
57
57
58
58
/*
59
59
* used to pass all arguments to mysql_real_connect while inside
60
- * rb_thread_blocking_region
60
+ * rb_thread_call_without_gvl
61
61
*/
62
62
struct nogvl_connect_args {
63
63
MYSQL * mysql ;
@@ -72,7 +72,7 @@ struct nogvl_connect_args {
72
72
73
73
/*
74
74
* used to pass all arguments to mysql_send_query while inside
75
- * rb_thread_blocking_region
75
+ * rb_thread_call_without_gvl
76
76
*/
77
77
struct nogvl_send_query_args {
78
78
MYSQL * mysql ;
@@ -84,7 +84,7 @@ struct nogvl_send_query_args {
84
84
85
85
/*
86
86
* used to pass all arguments to mysql_select_db while inside
87
- * rb_thread_blocking_region
87
+ * rb_thread_call_without_gvl
88
88
*/
89
89
struct nogvl_select_db_args {
90
90
MYSQL * mysql ;
@@ -144,15 +144,15 @@ static VALUE rb_raise_mysql2_error(mysql_client_wrapper *wrapper) {
144
144
return Qnil ;
145
145
}
146
146
147
- static VALUE nogvl_init (void * ptr ) {
147
+ static void * nogvl_init (void * ptr ) {
148
148
MYSQL * client ;
149
149
150
150
/* may initialize embedded server and read /etc/services off disk */
151
151
client = mysql_init ((MYSQL * )ptr );
152
- return client ? Qtrue : Qfalse ;
152
+ return ( void * )( client ? Qtrue : Qfalse ) ;
153
153
}
154
154
155
- static VALUE nogvl_connect (void * ptr ) {
155
+ static void * nogvl_connect (void * ptr ) {
156
156
struct nogvl_connect_args * args = ptr ;
157
157
MYSQL * client ;
158
158
@@ -161,10 +161,10 @@ static VALUE nogvl_connect(void *ptr) {
161
161
args -> db , args -> port , args -> unix_socket ,
162
162
args -> client_flag );
163
163
164
- return client ? Qtrue : Qfalse ;
164
+ return ( void * )( client ? Qtrue : Qfalse ) ;
165
165
}
166
166
167
- static VALUE nogvl_close (void * ptr ) {
167
+ static void * nogvl_close (void * ptr ) {
168
168
mysql_client_wrapper * wrapper ;
169
169
#ifndef _WIN32
170
170
int flags ;
@@ -191,7 +191,7 @@ static VALUE nogvl_close(void *ptr) {
191
191
mysql_close (wrapper -> client );
192
192
}
193
193
194
- return Qnil ;
194
+ return NULL ;
195
195
}
196
196
197
197
static void rb_mysql_client_free (void * ptr ) {
@@ -293,11 +293,11 @@ static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE po
293
293
args .mysql = wrapper -> client ;
294
294
args .client_flag = NUM2ULONG (flags );
295
295
296
- rv = rb_thread_blocking_region (nogvl_connect , & args , RUBY_UBF_IO , 0 );
296
+ rv = ( VALUE ) rb_thread_call_without_gvl (nogvl_connect , & args , RUBY_UBF_IO , 0 );
297
297
if (rv == Qfalse ) {
298
298
while (rv == Qfalse && errno == EINTR && !mysql_errno (wrapper -> client )) {
299
299
errno = 0 ;
300
- rv = rb_thread_blocking_region (nogvl_connect , & args , RUBY_UBF_IO , 0 );
300
+ rv = ( VALUE ) rb_thread_call_without_gvl (nogvl_connect , & args , RUBY_UBF_IO , 0 );
301
301
}
302
302
if (rv == Qfalse )
303
303
return rb_raise_mysql2_error (wrapper );
@@ -317,7 +317,7 @@ static VALUE rb_mysql_client_close(VALUE self) {
317
317
GET_CLIENT (self );
318
318
319
319
if (wrapper -> connected ) {
320
- rb_thread_blocking_region (nogvl_close , wrapper , RUBY_UBF_IO , 0 );
320
+ rb_thread_call_without_gvl (nogvl_close , wrapper , RUBY_UBF_IO , 0 );
321
321
}
322
322
323
323
return Qnil ;
@@ -328,19 +328,19 @@ static VALUE rb_mysql_client_close(VALUE self) {
328
328
* enough to fit in a socket buffer, but sometimes large UPDATE and
329
329
* INSERTs will cause the process to block
330
330
*/
331
- static VALUE nogvl_send_query (void * ptr ) {
331
+ static void * nogvl_send_query (void * ptr ) {
332
332
struct nogvl_send_query_args * args = ptr ;
333
333
int rv ;
334
334
335
335
rv = mysql_send_query (args -> mysql , args -> sql_ptr , args -> sql_len );
336
336
337
- return rv == 0 ? Qtrue : Qfalse ;
337
+ return ( void * )( rv == 0 ? Qtrue : Qfalse ) ;
338
338
}
339
339
340
340
static VALUE do_send_query (void * args ) {
341
341
struct nogvl_send_query_args * query_args = args ;
342
342
mysql_client_wrapper * wrapper = query_args -> wrapper ;
343
- if (rb_thread_blocking_region (nogvl_send_query , args , RUBY_UBF_IO , 0 ) == Qfalse ) {
343
+ if (( VALUE ) rb_thread_call_without_gvl (nogvl_send_query , args , RUBY_UBF_IO , 0 ) == Qfalse ) {
344
344
/* an error occurred, we're not active anymore */
345
345
MARK_CONN_INACTIVE (self );
346
346
return rb_raise_mysql2_error (wrapper );
@@ -353,14 +353,14 @@ static VALUE do_send_query(void *args) {
353
353
* response can overflow the socket buffers and cause us to eventually
354
354
* block while calling mysql_read_query_result
355
355
*/
356
- static VALUE nogvl_read_query_result (void * ptr ) {
356
+ static void * nogvl_read_query_result (void * ptr ) {
357
357
MYSQL * client = ptr ;
358
358
my_bool res = mysql_read_query_result (client );
359
359
360
- return res == 0 ? Qtrue : Qfalse ;
360
+ return ( void * )( res == 0 ? Qtrue : Qfalse ) ;
361
361
}
362
362
363
- static VALUE nogvl_do_result (void * ptr , char use_result ) {
363
+ static void * nogvl_do_result (void * ptr , char use_result ) {
364
364
mysql_client_wrapper * wrapper ;
365
365
MYSQL_RES * result ;
366
366
@@ -375,15 +375,15 @@ static VALUE nogvl_do_result(void *ptr, char use_result) {
375
375
ready for another command to be issued */
376
376
wrapper -> active_thread = Qnil ;
377
377
378
- return ( VALUE ) result ;
378
+ return result ;
379
379
}
380
380
381
381
/* mysql_store_result may (unlikely) read rows off the socket */
382
- static VALUE nogvl_store_result (void * ptr ) {
382
+ static void * nogvl_store_result (void * ptr ) {
383
383
return nogvl_do_result (ptr , 0 );
384
384
}
385
385
386
- static VALUE nogvl_use_result (void * ptr ) {
386
+ static void * nogvl_use_result (void * ptr ) {
387
387
return nogvl_do_result (ptr , 1 );
388
388
}
389
389
@@ -403,17 +403,17 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
403
403
return Qnil ;
404
404
405
405
REQUIRE_CONNECTED (wrapper );
406
- if (rb_thread_blocking_region (nogvl_read_query_result , wrapper -> client , RUBY_UBF_IO , 0 ) == Qfalse ) {
406
+ if (( VALUE ) rb_thread_call_without_gvl (nogvl_read_query_result , wrapper -> client , RUBY_UBF_IO , 0 ) == Qfalse ) {
407
407
/* an error occurred, mark this connection inactive */
408
408
MARK_CONN_INACTIVE (self );
409
409
return rb_raise_mysql2_error (wrapper );
410
410
}
411
411
412
412
is_streaming = rb_hash_aref (rb_iv_get (self , "@current_query_options" ), sym_stream );
413
413
if (is_streaming == Qtrue ) {
414
- result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_use_result , wrapper , RUBY_UBF_IO , 0 );
414
+ result = (MYSQL_RES * )rb_thread_call_without_gvl (nogvl_use_result , wrapper , RUBY_UBF_IO , 0 );
415
415
} else {
416
- result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
416
+ result = (MYSQL_RES * )rb_thread_call_without_gvl (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
417
417
}
418
418
419
419
if (result == NULL ) {
@@ -512,7 +512,7 @@ static VALUE finish_and_mark_inactive(void *args) {
512
512
/* if we got here, the result hasn't been read off the wire yet
513
513
so lets do that and then throw it away because we have no way
514
514
of getting it back up to the caller from here */
515
- result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
515
+ result = (MYSQL_RES * )rb_thread_call_without_gvl (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
516
516
mysql_free_result (result );
517
517
518
518
wrapper -> active_thread = Qnil ;
@@ -542,7 +542,7 @@ static VALUE rb_mysql_client_abandon_results(VALUE self) {
542
542
rb_raise_mysql2_error (wrapper );
543
543
}
544
544
545
- result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
545
+ result = (MYSQL_RES * )rb_thread_call_without_gvl (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
546
546
547
547
if (result != NULL ) {
548
548
mysql_free_result (result );
@@ -866,13 +866,13 @@ static VALUE rb_mysql_client_thread_id(VALUE self) {
866
866
return ULL2NUM (retVal );
867
867
}
868
868
869
- static VALUE nogvl_select_db (void * ptr ) {
869
+ static void * nogvl_select_db (void * ptr ) {
870
870
struct nogvl_select_db_args * args = ptr ;
871
871
872
872
if (mysql_select_db (args -> mysql , args -> db ) == 0 )
873
- return Qtrue ;
873
+ return ( void * ) Qtrue ;
874
874
else
875
- return Qfalse ;
875
+ return ( void * ) Qfalse ;
876
876
}
877
877
878
878
/* call-seq:
@@ -891,16 +891,16 @@ static VALUE rb_mysql_client_select_db(VALUE self, VALUE db)
891
891
args .mysql = wrapper -> client ;
892
892
args .db = StringValuePtr (db );
893
893
894
- if (rb_thread_blocking_region (nogvl_select_db , & args , RUBY_UBF_IO , 0 ) == Qfalse )
894
+ if (rb_thread_call_without_gvl (nogvl_select_db , & args , RUBY_UBF_IO , 0 ) == Qfalse )
895
895
rb_raise_mysql2_error (wrapper );
896
896
897
897
return db ;
898
898
}
899
899
900
- static VALUE nogvl_ping (void * ptr ) {
900
+ static void * nogvl_ping (void * ptr ) {
901
901
MYSQL * client = ptr ;
902
902
903
- return mysql_ping (client ) == 0 ? Qtrue : Qfalse ;
903
+ return ( void * )( mysql_ping (client ) == 0 ? Qtrue : Qfalse ) ;
904
904
}
905
905
906
906
/* call-seq:
@@ -917,7 +917,7 @@ static VALUE rb_mysql_client_ping(VALUE self) {
917
917
if (!wrapper -> connected ) {
918
918
return Qfalse ;
919
919
} else {
920
- return rb_thread_blocking_region (nogvl_ping , wrapper -> client , RUBY_UBF_IO , 0 );
920
+ return ( VALUE ) rb_thread_call_without_gvl (nogvl_ping , wrapper -> client , RUBY_UBF_IO , 0 );
921
921
}
922
922
}
923
923
@@ -969,7 +969,7 @@ static VALUE rb_mysql_client_store_result(VALUE self)
969
969
VALUE current ;
970
970
GET_CLIENT (self );
971
971
972
- result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
972
+ result = (MYSQL_RES * )rb_thread_call_without_gvl (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
973
973
974
974
if (result == NULL ) {
975
975
if (mysql_errno (wrapper -> client ) != 0 ) {
@@ -1101,7 +1101,7 @@ static VALUE set_secure_auth(VALUE self, VALUE value) {
1101
1101
static VALUE initialize_ext (VALUE self ) {
1102
1102
GET_CLIENT (self );
1103
1103
1104
- if (rb_thread_blocking_region (nogvl_init , wrapper -> client , RUBY_UBF_IO , 0 ) == Qfalse ) {
1104
+ if (( VALUE ) rb_thread_call_without_gvl (nogvl_init , wrapper -> client , RUBY_UBF_IO , 0 ) == Qfalse ) {
1105
1105
/* TODO: warning - not enough memory? */
1106
1106
return rb_raise_mysql2_error (wrapper );
1107
1107
}
0 commit comments