def send_message(operation, message, opts={})
if opts.is_a?(String)
warn "MongoClient#send_message no longer takes a string log message. " +
"Logging is now handled within the Collection and Cursor classes."
opts = {}
end
add_message_headers(message, operation)
packed_message = message.to_s
sock = nil
pool = opts.fetch(:pool, nil)
begin
if pool
sock = pool.checkout
else
sock ||= checkout_writer
end
send_message_on_socket(packed_message, sock)
rescue SystemStackError, NoMemoryError, SystemCallError => ex
close
raise ex
ensure
if sock
sock.checkin
end
end
end