Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/mongo/cluster/reapers/cursor_reaper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ def kill_cursors
end

unless server
# TODO: We currently don't have a server for the address that the
# cursor is associated with. We should leave the cursor in the
# queue to be killed at a later time (when the server comes back).
# The server for this cursor has gone away --- maybe temporarily,
# maybe permanently, but we can't know. To prevent connections from
# leaking in the case of a permanent failure, we'll just silently
# drop this killspec and move on.
next
end

Expand Down
21 changes: 2 additions & 19 deletions lib/mongo/cluster_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ module Mongo
#
# @api private
class ClusterTime < BSON::Document
include Comparable

def initialize(elements = nil)
super

Expand Down Expand Up @@ -62,25 +64,6 @@ def <=>(other)
end
end

# Older Rubies do not implement other logical operators through <=>.
# TODO revise whether these methods are needed when
# https://jira.mongodb.org/browse/RUBY-1622 is implemented.
def >=(other)
(self <=> other) != -1
end

def >(other)
(self <=> other) == 1
end

def <=(other)
(self <=> other) != 1
end

def <(other)
(self <=> other) == -1
end

# Compares two ClusterTime instances by comparing their timestamps.
def ==(other)
if self['clusterTime'] && other['clusterTime'] &&
Expand Down
3 changes: 0 additions & 3 deletions lib/mongo/operation/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ class Result
def initialize(replies, connection_description = nil, connection_global_id = nil, context: nil, connection: nil)
@context = context

# TODO: older versions of MongoDB (2.4 and below?) could sometimes end
# up with nil here, which indicated an unackowledged write. Is that
# still the case? Can we simplify this?
return unless replies

if replies.is_a?(Array)
Expand Down
2 changes: 0 additions & 2 deletions lib/mongo/protocol/msg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ def documents
# @return [ Mongo::Protocol::Msg ] The encrypted message, or the original
# message if encryption was not possible or necessary.
def maybe_encrypt(connection, context)
# TODO: verify compression happens later, i.e. when this method runs
# the message is not compressed.
if context.encrypt?
if connection.description.max_wire_version < 8
raise Error::CryptError.new(
Expand Down
2 changes: 1 addition & 1 deletion lib/mongo/socket/ocsp_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Socket
# This module caches OCSP responses for their indicated validity time.
#
# The key is the CertificateId used for the OCSP request.
# The value is the SingleResponse.
# The value is an OcspVerifier::Response.
#
Comment on lines 19 to 23
# @api private
module OcspCache
Expand Down
26 changes: 18 additions & 8 deletions lib/mongo/socket/ocsp_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'delegate'

module Net
autoload :HTTP, 'net/http'
end
Expand All @@ -31,6 +33,19 @@ class Socket
#
# @api private
class OcspVerifier
# Wraps OpenSSL::OCSP::SingleResponse with the responder URI that supplied it.
#
# @api private
class Response < SimpleDelegator
attr_reader :uri, :original_uri

def initialize(single_response, uri, original_uri)
super(single_response)
@uri = uri
@original_uri = original_uri
end
end

include Loggable

# @param [ String ] host_name The host name being verified, for
Expand Down Expand Up @@ -228,18 +243,13 @@ def verify_one_responder(uri)
return false
end

resp = resp.find_response(cert_id)
unless resp
single_response = resp.find_response(cert_id)
unless single_response
@resp_errors << "OCSP response from #{report_uri(original_uri,
uri)} did not include information about the requested certificate"
return false
end
# TODO: make a new class instead of patching the stdlib one?
resp.instance_variable_set(:@uri, uri)
resp.instance_variable_set(:@original_uri, original_uri)
class << resp
attr_reader :uri, :original_uri
end
resp = Response.new(single_response, uri, original_uri)

unless resp.check_validity
@resp_errors << "OCSP response from #{report_uri(original_uri,
Expand Down
Loading