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)
923923 return rb_str_new2 (cwrap -> identity_insert_sql );
924924}
925925
926+ // connect function, with some additions to enable handing off the GVL
927+ struct dbuse_args {
928+ DBPROCESS * dbproc ;
929+ const char * name ;
930+ };
926931
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+ }
927938
928- // TinyTds::Client (protected)
929939
930940static VALUE rb_tinytds_connect (VALUE self )
931941{
@@ -1023,7 +1033,20 @@ static VALUE rb_tinytds_connect(VALUE self)
10231033 cwrap -> userdata -> closed = 0 ;
10241034
10251035 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 );
10271050 }
10281051
10291052 cwrap -> encoding = rb_enc_find (StringValueCStr (charset ));
You can’t perform that action at this time.
0 commit comments