Connection#send_message should return bytes sent

This commit is contained in:
Kyle Banker 2010-07-27 22:19:25 -04:00
parent 182b53d41f
commit 66e9508f61
2 changed files with 11 additions and 1 deletions

View File

@ -376,7 +376,7 @@ module Mongo
# @param [BSON::ByteBuffer] message a message to send to the database.
# @param [String] log_message text version of +message+ for logging.
#
# @return [True]
# @return [Integer] number of bytes sent
def send_message(operation, message, log_message=nil)
@logger.debug(" MONGODB #{log_message || message}") if @logger
begin
@ -812,12 +812,17 @@ module Mongo
# Low-level method for sending a message on a socket.
# Requires a packed message and an available socket,
#
# @return [Integer] number of bytes sent
def send_message_on_socket(packed_message, socket)
begin
total_bytes_sent = 0
while packed_message.size > 0
byte_sent = socket.send(packed_message, 0)
total_bytes_sent += byte_sent
packed_message.slice!(0, byte_sent)
end
total_bytes_sent
rescue => ex
close
raise ConnectionFailure, "Operation failed with the following exception: #{ex}"

View File

@ -259,6 +259,11 @@ class TestCollection < Test::Unit::TestCase
@test.drop
end
def test_remove_return_value
assert_equal 50, @@test.remove({})
assert_equal 57, @@test.remove({"x" => 1})
end
def test_count
@@test.drop