Fixes for 1.9.1 compatibility.
This commit is contained in:
parent
072b025cdc
commit
cdb60b378f
6
Rakefile
6
Rakefile
|
@ -19,6 +19,7 @@ desc "Test the MongoDB Ruby driver."
|
||||||
task :test do
|
task :test do
|
||||||
Rake::Task['test:unit'].invoke
|
Rake::Task['test:unit'].invoke
|
||||||
Rake::Task['test:functional'].invoke
|
Rake::Task['test:functional'].invoke
|
||||||
|
Rake::Task['test:pooled_threading'].invoke
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
|
@ -32,6 +33,11 @@ namespace :test do
|
||||||
t.verbose = true
|
t.verbose = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Rake::TestTask.new(:pooled_threading) do |t|
|
||||||
|
t.test_files = FileList['test/threading/*.rb']
|
||||||
|
t.verbose = true
|
||||||
|
end
|
||||||
|
|
||||||
Rake::TestTask.new(:pair_count) do |t|
|
Rake::TestTask.new(:pair_count) do |t|
|
||||||
t.test_files = FileList['test/replica/count_test.rb']
|
t.test_files = FileList['test/replica/count_test.rb']
|
||||||
t.verbose = true
|
t.verbose = true
|
||||||
|
|
|
@ -383,7 +383,7 @@ module Mongo
|
||||||
next if @checked_out.size < @sockets.size
|
next if @checked_out.size < @sockets.size
|
||||||
|
|
||||||
# Otherwise, wait.
|
# Otherwise, wait.
|
||||||
if @queue.wait(@timeout)
|
if wait
|
||||||
next
|
next
|
||||||
else
|
else
|
||||||
|
|
||||||
|
@ -399,6 +399,20 @@ module Mongo
|
||||||
end # synchronize
|
end # synchronize
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if RUBY_VERSION >= '1.9'
|
||||||
|
# Ruby 1.9's Condition Variables don't support timeouts yet;
|
||||||
|
# until they do, we'll make do with this hack.
|
||||||
|
def wait
|
||||||
|
Timeout.timeout(@timeout) do
|
||||||
|
@queue.wait
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
def wait
|
||||||
|
@queue.wait(@timeout)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def receive(sock)
|
def receive(sock)
|
||||||
receive_header(sock)
|
receive_header(sock)
|
||||||
number_received, cursor_id = receive_response_header(sock)
|
number_received, cursor_id = receive_response_header(sock)
|
||||||
|
|
|
@ -305,7 +305,7 @@ module Mongo
|
||||||
sel = {:ns => full_collection_name(collection_name)}
|
sel = {:ns => full_collection_name(collection_name)}
|
||||||
info = {}
|
info = {}
|
||||||
Cursor.new(Collection.new(self, SYSTEM_INDEX_COLLECTION), :selector => sel).each { |index|
|
Cursor.new(Collection.new(self, SYSTEM_INDEX_COLLECTION), :selector => sel).each { |index|
|
||||||
info[index['name']] = index['key'].map
|
info[index['name']] = index['key'].map {|k| k}
|
||||||
}
|
}
|
||||||
info
|
info
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,21 +43,21 @@ class TestThreadingLargePool < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_safe_insert
|
def test_safe_insert
|
||||||
set_up_safe_data
|
set_up_safe_data
|
||||||
threads = []
|
threads = []
|
||||||
100.times do |i|
|
100.times do |i|
|
||||||
threads[i] = Thread.new do
|
threads[i] = Thread.new do
|
||||||
if i % 2 == 0
|
if i % 2 == 0
|
||||||
assert_raise Mongo::OperationFailure do
|
assert_raise Mongo::OperationFailure do
|
||||||
@unique.insert({"test" => "insert"}, :safe => true)
|
@unique.insert({"test" => "insert"}, :safe => true)
|
||||||
end
|
|
||||||
else
|
|
||||||
@duplicate.insert({"test" => "insert"}, :safe => true)
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@duplicate.insert({"test" => "insert"}, :safe => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
100.times do |i|
|
100.times do |i|
|
||||||
threads[i].join
|
threads[i].join
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue