Connection#send_message should return bytes sent
This commit is contained in:
parent
182b53d41f
commit
66e9508f61
|
@ -376,7 +376,7 @@ module Mongo
|
||||||
# @param [BSON::ByteBuffer] message a message to send to the database.
|
# @param [BSON::ByteBuffer] message a message to send to the database.
|
||||||
# @param [String] log_message text version of +message+ for logging.
|
# @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)
|
def send_message(operation, message, log_message=nil)
|
||||||
@logger.debug(" MONGODB #{log_message || message}") if @logger
|
@logger.debug(" MONGODB #{log_message || message}") if @logger
|
||||||
begin
|
begin
|
||||||
|
@ -812,12 +812,17 @@ module Mongo
|
||||||
|
|
||||||
# Low-level method for sending a message on a socket.
|
# Low-level method for sending a message on a socket.
|
||||||
# Requires a packed message and an available socket,
|
# Requires a packed message and an available socket,
|
||||||
|
#
|
||||||
|
# @return [Integer] number of bytes sent
|
||||||
def send_message_on_socket(packed_message, socket)
|
def send_message_on_socket(packed_message, socket)
|
||||||
begin
|
begin
|
||||||
|
total_bytes_sent = 0
|
||||||
while packed_message.size > 0
|
while packed_message.size > 0
|
||||||
byte_sent = socket.send(packed_message, 0)
|
byte_sent = socket.send(packed_message, 0)
|
||||||
|
total_bytes_sent += byte_sent
|
||||||
packed_message.slice!(0, byte_sent)
|
packed_message.slice!(0, byte_sent)
|
||||||
end
|
end
|
||||||
|
total_bytes_sent
|
||||||
rescue => ex
|
rescue => ex
|
||||||
close
|
close
|
||||||
raise ConnectionFailure, "Operation failed with the following exception: #{ex}"
|
raise ConnectionFailure, "Operation failed with the following exception: #{ex}"
|
||||||
|
|
|
@ -259,6 +259,11 @@ class TestCollection < Test::Unit::TestCase
|
||||||
@test.drop
|
@test.drop
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_remove_return_value
|
||||||
|
assert_equal 50, @@test.remove({})
|
||||||
|
assert_equal 57, @@test.remove({"x" => 1})
|
||||||
|
end
|
||||||
|
|
||||||
def test_count
|
def test_count
|
||||||
@@test.drop
|
@@test.drop
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue