attempt to not blow up on ctrl+c during connect--that might have been a problem

This commit is contained in:
Roger Pack 2009-04-21 02:13:24 +00:00
parent 52d95ff3e8
commit d1433a549e
3 changed files with 18 additions and 1 deletions

View File

@ -389,7 +389,7 @@ static VALUE real_connect(int argc, VALUE* argv, VALUE klass) /* actually gets r
#if MYSQL_VERSION_ID >= 32200
mysql_init(&myp->handler); /* we get here */
# 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
if(mysql_real_connect(&myp->handler, h, u, p, d, pp, s, f) == NULL)
# endif

View 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

View File

@ -11,6 +11,7 @@ begin
Mysql.real_connect('localhost', 'root', 'pass', 'db', 3307)# bad port
rescue Mysql::Error
end
print "pass"