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 = opts.fetch(:socket, nil)
begin
if operation == Mongo::Constants::OP_KILL_CURSORS && @read != :primary
sock ||= checkout_reader
else
sock ||= checkout_writer
end
send_message_on_socket(packed_message, sock)
rescue SystemStackError, NoMemoryError, SystemCallError => ex
close
raise ex
ensure
if sock
sock.pool.checkin(sock)
end
end
end