moped 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of moped might be problematic. Click here for more details.
- data/CHANGELOG.md +8 -1
- data/lib/moped/collection.rb +1 -1
- data/lib/moped/connection.rb +29 -7
- data/lib/moped/version.rb +1 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Overview
|
2
2
|
|
3
|
-
## 1.2.
|
3
|
+
## 1.2.9
|
4
|
+
|
5
|
+
* Moped now ensures that when reading bytes from the socket that it continues
|
6
|
+
to read until the requested number of bytes have been received. In the case
|
7
|
+
of getting `nil` back it will raise a `ConnectionFailure` and go through the
|
8
|
+
normal failover motions.
|
9
|
+
|
10
|
+
## 1.2.8
|
4
11
|
|
5
12
|
### Resolved Issues
|
6
13
|
|
data/lib/moped/collection.rb
CHANGED
data/lib/moped/connection.rb
CHANGED
@@ -85,10 +85,7 @@ module Moped
|
|
85
85
|
def read
|
86
86
|
with_connection do |socket|
|
87
87
|
reply = Protocol::Reply.allocate
|
88
|
-
data = socket
|
89
|
-
unless data
|
90
|
-
raise Errors::ConnectionFailure, "Attempted read from socket which returned no data."
|
91
|
-
end
|
88
|
+
data = read_data(socket, 36)
|
92
89
|
response = data.unpack('l<5q<l<2')
|
93
90
|
reply.length,
|
94
91
|
reply.request_id,
|
@@ -102,10 +99,8 @@ module Moped
|
|
102
99
|
if reply.count == 0
|
103
100
|
reply.documents = []
|
104
101
|
else
|
105
|
-
sock_read = socket
|
106
|
-
|
102
|
+
sock_read = read_data(socket, reply.length - 36)
|
107
103
|
buffer = StringIO.new(sock_read)
|
108
|
-
|
109
104
|
reply.documents = reply.count.times.map do
|
110
105
|
BSON::Document.deserialize(buffer)
|
111
106
|
end
|
@@ -157,6 +152,33 @@ module Moped
|
|
157
152
|
@sock = TCPSocket.connect @host, @port, @timeout
|
158
153
|
end
|
159
154
|
|
155
|
+
# Read data from the socket until we get back the number of bytes that we
|
156
|
+
# are expecting.
|
157
|
+
#
|
158
|
+
# @api private
|
159
|
+
#
|
160
|
+
# @example Read the number of bytes.
|
161
|
+
# connection.read_data(socket, 36)
|
162
|
+
#
|
163
|
+
# @param [ TCPSocket ] socket The socket to read from.
|
164
|
+
# @param [ Integer ] length The number of bytes to read.
|
165
|
+
#
|
166
|
+
# @return [ String ] The read data.
|
167
|
+
#
|
168
|
+
# @since 1.2.9
|
169
|
+
def read_data(socket, length)
|
170
|
+
data = socket.read(length)
|
171
|
+
unless data
|
172
|
+
raise Errors::ConnectionFailure.new(
|
173
|
+
"Attempted to read #{length} bytes from the socket but nothing was returned."
|
174
|
+
)
|
175
|
+
end
|
176
|
+
if data.length < length
|
177
|
+
data << read_data(socket, length - data.length)
|
178
|
+
end
|
179
|
+
data
|
180
|
+
end
|
181
|
+
|
160
182
|
# Yields a connected socket to the calling back. It will attempt to reconnect
|
161
183
|
# the socket if it is not connected.
|
162
184
|
#
|
data/lib/moped/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moped
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A MongoDB driver for Ruby.
|
15
15
|
email:
|
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: 450437274289811416
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
none: false
|
91
91
|
requirements:
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
segments:
|
96
96
|
- 0
|
97
|
-
hash:
|
97
|
+
hash: 450437274289811416
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
100
|
rubygems_version: 1.8.24
|