File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -923,9 +923,19 @@ static VALUE rb_tinytds_identity_sql(VALUE self)
923
923
return rb_str_new2 (cwrap -> identity_insert_sql );
924
924
}
925
925
926
+ // connect function, with some additions to enable handing off the GVL
927
+ struct dbuse_args {
928
+ DBPROCESS * dbproc ;
929
+ const char * name ;
930
+ };
926
931
932
+ static void * dbuse_without_gvl (void * ptr )
933
+ {
934
+ struct dbuse_args * args = (struct dbuse_args * )ptr ;
935
+ dbuse (args -> dbproc , args -> name );
936
+ return NULL ;
937
+ }
927
938
928
- // TinyTds::Client (protected)
929
939
930
940
static VALUE rb_tinytds_connect (VALUE self )
931
941
{
@@ -1023,7 +1033,20 @@ static VALUE rb_tinytds_connect(VALUE self)
1023
1033
cwrap -> userdata -> closed = 0 ;
1024
1034
1025
1035
if (!NIL_P (database ) && (azure != Qtrue )) {
1026
- dbuse (cwrap -> client , StringValueCStr (database ));
1036
+ struct dbuse_args use_args ;
1037
+ use_args .dbproc = cwrap -> client ;
1038
+ use_args .name = StringValueCStr (database );
1039
+
1040
+ // in case of any errors, the tinytds_err_handler will be called
1041
+ // so we do not have to check the return code here
1042
+ nogvl_setup (cwrap -> client );
1043
+ rb_thread_call_without_gvl (
1044
+ dbuse_without_gvl ,
1045
+ & use_args ,
1046
+ NULL ,
1047
+ NULL
1048
+ );
1049
+ nogvl_cleanup (cwrap -> client );
1027
1050
}
1028
1051
1029
1052
cwrap -> encoding = rb_enc_find (StringValueCStr (charset ));
You can’t perform that action at this time.
0 commit comments