Merge branch 'master' into stmt
* master: Detach before executing callbacks. make sure we don't hit a race condition if this EM spec is taking longer to run than normal was in a hurry earlier whoops, lost this line in a previous patch Dry windows configuration options Inject 1.8/1.9 pure-ruby entry point during xcompile Use MySQL 5.1.51 now from available mirror
This commit is contained in:
commit
7b6d210c97
@ -140,6 +140,7 @@ static VALUE nogvl_close(void * ptr) {
|
|||||||
mysql_client_wrapper *wrapper = ptr;
|
mysql_client_wrapper *wrapper = ptr;
|
||||||
if (!wrapper->closed) {
|
if (!wrapper->closed) {
|
||||||
mysql_close(wrapper->client);
|
mysql_close(wrapper->client);
|
||||||
|
wrapper->client->net.fd = -1;
|
||||||
wrapper->closed = 1;
|
wrapper->closed = 1;
|
||||||
}
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
@ -13,12 +13,12 @@ module Mysql2
|
|||||||
end
|
end
|
||||||
|
|
||||||
def notify_readable
|
def notify_readable
|
||||||
|
detach
|
||||||
begin
|
begin
|
||||||
@deferable.succeed(@client.async_result)
|
@deferable.succeed(@client.async_result)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@deferable.fail(e)
|
@deferable.fail(e)
|
||||||
end
|
end
|
||||||
detach
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ describe Mysql2::EM::Client do
|
|||||||
results = []
|
results = []
|
||||||
EM.run do
|
EM.run do
|
||||||
client1 = Mysql2::EM::Client.new
|
client1 = Mysql2::EM::Client.new
|
||||||
defer1 = client1.query "SELECT sleep(0.05) as first_query"
|
defer1 = client1.query "SELECT sleep(0.1) as first_query"
|
||||||
defer1.callback do |result|
|
defer1.callback do |result|
|
||||||
results << result.first
|
results << result.first
|
||||||
EM.stop_event_loop
|
EM.stop_event_loop
|
||||||
@ -19,8 +19,27 @@ describe Mysql2::EM::Client do
|
|||||||
results << result.first
|
results << result.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
results[0].keys.should include("second_query")
|
results[0].keys.should include("second_query")
|
||||||
results[1].keys.should include("first_query")
|
results[1].keys.should include("first_query")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should support queries in callbacks" do
|
||||||
|
results = []
|
||||||
|
EM.run do
|
||||||
|
client = Mysql2::EM::Client.new
|
||||||
|
defer1 = client.query "SELECT sleep(0.025) as first_query"
|
||||||
|
defer1.callback do |result|
|
||||||
|
results << result.first
|
||||||
|
defer2 = client.query "SELECT sleep(0.025) as second_query"
|
||||||
|
defer2.callback do |result|
|
||||||
|
results << result.first
|
||||||
|
EM.stop_event_loop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
results[0].keys.should include("first_query")
|
||||||
|
results[1].keys.should include("second_query")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
gem 'rake-compiler', '~> 0.7.1'
|
gem 'rake-compiler', '~> 0.7.1'
|
||||||
require "rake/extensiontask"
|
require "rake/extensiontask"
|
||||||
|
|
||||||
MYSQL_VERSION = "5.1.50"
|
MYSQL_VERSION = "5.1.51"
|
||||||
MYSQL_MIRROR = ENV['MYSQL_MIRROR'] || "http://mysql.mirrors.pair.com"
|
MYSQL_MIRROR = ENV['MYSQL_MIRROR'] || "http://mysql.he.net/"
|
||||||
|
|
||||||
|
|
||||||
def gemspec
|
def gemspec
|
||||||
@clean_gemspec ||= eval(File.read(File.expand_path('../../mysql2.gemspec', __FILE__)))
|
@clean_gemspec ||= eval(File.read(File.expand_path('../../mysql2.gemspec', __FILE__)))
|
||||||
@ -13,15 +12,24 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
|
|||||||
# reference where the vendored MySQL got extracted
|
# reference where the vendored MySQL got extracted
|
||||||
mysql_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-#{MYSQL_VERSION}-win32"))
|
mysql_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-#{MYSQL_VERSION}-win32"))
|
||||||
|
|
||||||
|
# DRY options feed into compile or cross-compile process
|
||||||
|
windows_options = [
|
||||||
|
"--with-mysql-include=#{mysql_lib}/include",
|
||||||
|
"--with-mysql-lib=#{mysql_lib}/lib/opt"
|
||||||
|
]
|
||||||
|
|
||||||
# automatically add build options to avoid need of manual input
|
# automatically add build options to avoid need of manual input
|
||||||
if RUBY_PLATFORM =~ /mswin|mingw/ then
|
if RUBY_PLATFORM =~ /mswin|mingw/ then
|
||||||
ext.config_options << "--with-mysql-include=#{mysql_lib}/include"
|
ext.config_options = windows_options
|
||||||
ext.config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
|
|
||||||
else
|
else
|
||||||
ext.cross_compile = true
|
ext.cross_compile = true
|
||||||
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
|
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
|
||||||
ext.cross_config_options << "--with-mysql-include=#{mysql_lib}/include"
|
ext.cross_config_options = windows_options
|
||||||
ext.cross_config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
|
|
||||||
|
# inject 1.8/1.9 pure-ruby entry point when cross compiling only
|
||||||
|
ext.cross_compiling do |spec|
|
||||||
|
spec.files << 'lib/mysql2/mysql2.rb'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ext.lib_dir = File.join 'lib', 'mysql2'
|
ext.lib_dir = File.join 'lib', 'mysql2'
|
||||||
@ -31,25 +39,16 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
|
|||||||
end
|
end
|
||||||
Rake::Task[:spec].prerequisites << :compile
|
Rake::Task[:spec].prerequisites << :compile
|
||||||
|
|
||||||
namespace :cross do
|
file 'lib/mysql2/mysql2.rb' do |t|
|
||||||
task :file_list do
|
|
||||||
gemspec.extensions = []
|
|
||||||
gemspec.files += Dir["lib/#{gemspec.name}/#{gemspec.name}.rb"]
|
|
||||||
gemspec.files += Dir["lib/#{gemspec.name}/1.{8,9}/#{gemspec.name}.so"]
|
|
||||||
# gemspec.files += Dir["ext/mysql2/*.dll"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
file 'lib/mysql2/mysql2.rb' do
|
|
||||||
name = gemspec.name
|
name = gemspec.name
|
||||||
File.open("lib/#{name}/#{name}.rb", 'wb') do |f|
|
File.open(t.name, 'wb') do |f|
|
||||||
f.write <<-eoruby
|
f.write <<-eoruby
|
||||||
require "#{name}/\#{RUBY_VERSION.sub(/\\.\\d+$/, '')}/#{name}"
|
RUBY_VERSION =~ /(\\d+.\\d+)/
|
||||||
|
require "#{name}/\#{$1}/#{name}"
|
||||||
eoruby
|
eoruby
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Rake::Task.task_defined?(:cross)
|
if Rake::Task.task_defined?(:cross)
|
||||||
Rake::Task[:cross].prerequisites << "lib/mysql2/mysql2.rb"
|
Rake::Task[:cross].prerequisites << "lib/mysql2/mysql2.rb"
|
||||||
Rake::Task[:cross].prerequisites << "cross:file_list"
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user