minor: pool test working for windows on 1.8.6

This commit is contained in:
Kyle Banker 2009-12-29 13:27:12 -05:00
parent e013618a8f
commit 7a08e2c84f

View File

@ -109,6 +109,7 @@ module Mongo
# Mutex for synchronizing pool access # Mutex for synchronizing pool access
@connection_mutex = Mutex.new @connection_mutex = Mutex.new
@safe_mutex = Mutex.new
# Condition variable for signal and wait # Condition variable for signal and wait
@queue = ConditionVariable.new @queue = ConditionVariable.new
@ -218,8 +219,11 @@ module Mongo
@logger.debug(" MONGODB #{log_message || message}") if @logger @logger.debug(" MONGODB #{log_message || message}") if @logger
sock = checkout sock = checkout
packed_message = message_with_headers.append!(message_with_check).to_s packed_message = message_with_headers.append!(message_with_check).to_s
docs = num_received = cursor_id = ''
@safe_mutex.synchronize do
send_message_on_socket(packed_message, sock) send_message_on_socket(packed_message, sock)
docs, num_received, cursor_id = receive(sock) docs, num_received, cursor_id = receive(sock)
end
checkin(sock) checkin(sock)
if num_received == 1 && error = docs[0]['err'] if num_received == 1 && error = docs[0]['err']
raise Mongo::OperationFailure, error raise Mongo::OperationFailure, error
@ -237,8 +241,11 @@ module Mongo
@logger.debug(" MONGODB #{log_message || message}") if @logger @logger.debug(" MONGODB #{log_message || message}") if @logger
sock = socket || checkout sock = socket || checkout
result = ''
@safe_mutex.synchronize do
send_message_on_socket(packed_message, sock) send_message_on_socket(packed_message, sock)
result = receive(sock) result = receive(sock)
end
checkin(sock) checkin(sock)
result result
end end