Do not schedule in a single threaded environment
This commit is contained in:
parent
48a61dd627
commit
4640893f27
12
ext/mysql.c
12
ext/mysql.c
@ -913,11 +913,10 @@ static void validate_async_query( VALUE obj )
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE simulate_disconnect( VALUE obj )
|
||||
static void simulate_disconnect( VALUE obj )
|
||||
{
|
||||
MYSQL* m = GetHandler(obj);
|
||||
mysql_library_end();
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static int begins_with_insensitive(char *candidate, char *check_for_in_upper_case)
|
||||
@ -978,6 +977,7 @@ static VALUE send_query(VALUE obj, VALUE sql)
|
||||
} else {
|
||||
async_in_progress_set( obj, Qtrue );
|
||||
}
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
@ -1034,6 +1034,10 @@ static void schedule_query(VALUE obj, VALUE timeout)
|
||||
}
|
||||
}
|
||||
|
||||
static int should_schedule_query(){
|
||||
return ( ( rb_thread_main() == rb_thread_current() ) && rb_thread_alone() );
|
||||
}
|
||||
|
||||
/* async_query(sql,timeout=nil) */
|
||||
static VALUE async_query(int argc, VALUE* argv, VALUE obj)
|
||||
{
|
||||
@ -1046,9 +1050,11 @@ static VALUE async_query(int argc, VALUE* argv, VALUE obj)
|
||||
|
||||
busy(obj);
|
||||
|
||||
send_query(obj,sql);
|
||||
send_query( obj, sql );
|
||||
|
||||
if ( should_schedule_query() != 1 ){
|
||||
schedule_query(obj, timeout);
|
||||
}
|
||||
|
||||
if (rb_block_given_p()) {
|
||||
rb_yield( get_result(obj) );
|
||||
|
Loading…
Reference in New Issue
Block a user