attempt to not blow up on ctrl+c during connect--that might have been a problem
This commit is contained in:
parent
52d95ff3e8
commit
d1433a549e
@ -389,7 +389,7 @@ static VALUE real_connect(int argc, VALUE* argv, VALUE klass) /* actually gets r
|
|||||||
#if MYSQL_VERSION_ID >= 32200
|
#if MYSQL_VERSION_ID >= 32200
|
||||||
mysql_init(&myp->handler); /* we get here */
|
mysql_init(&myp->handler); /* we get here */
|
||||||
# ifdef HAVE_TBR
|
# ifdef HAVE_TBR
|
||||||
if( (int) rb_thread_blocking_region_variable_params(10, &mysql_real_connect, 8, &myp->handler, h, u, p, d, pp, s, f) == NULL)
|
if( (int) rb_thread_blocking_region_variable_params(10, &mysql_real_connect, RUBY_UBF_IO, &myp->handler, h, u, p, d, pp, s, f) == NULL)
|
||||||
# else
|
# else
|
||||||
if(mysql_real_connect(&myp->handler, h, u, p, d, pp, s, f) == NULL)
|
if(mysql_real_connect(&myp->handler, h, u, p, d, pp, s, f) == NULL)
|
||||||
# endif
|
# endif
|
||||||
|
16
test/connect_failure2_test.rb
Normal file
16
test/connect_failure2_test.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
if RUBY_VERSION >= "1.9.1"
|
||||||
|
require 'mysqlplus'
|
||||||
|
require 'socket'
|
||||||
|
TCPServer.new '0.0.0.0', 8001
|
||||||
|
require 'timeout'
|
||||||
|
Timeout::timeout(1) {
|
||||||
|
# uncomment this line to do the 'real' test
|
||||||
|
# which hangs otherwise (blows up if code is bad, otherwise hangs)
|
||||||
|
# Mysql.real_connect '127.0.0.1', 'root', 'pass', 'db', 8000
|
||||||
|
}
|
||||||
|
Thread.new { Mysql.real_connect '127.0.0.1', 'root', 'pass', 'db', 8001 }
|
||||||
|
sleep 1
|
||||||
|
print "pass"
|
||||||
|
system("kill -9 #{Process.pid}")
|
||||||
|
end
|
||||||
|
|
@ -11,6 +11,7 @@ begin
|
|||||||
Mysql.real_connect('localhost', 'root', 'pass', 'db', 3307)# bad port
|
Mysql.real_connect('localhost', 'root', 'pass', 'db', 3307)# bad port
|
||||||
rescue Mysql::Error
|
rescue Mysql::Error
|
||||||
end
|
end
|
||||||
|
|
||||||
print "pass"
|
print "pass"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user