lib/mongo/cluster/reapers/cursor_reaper.rb in mongo-2.11.6 vs lib/mongo/cluster/reapers/cursor_reaper.rb in mongo-2.12.0.rc0

- old
+ new

@@ -74,15 +74,20 @@ # # @api private # # @since 2.3.0 def register_cursor(id) - if id && id > 0 - @mutex.synchronize do - @active_cursors << id - end + if id.nil? + raise ArgumentError, 'register_cursor called with nil cursor_id' end + if id == 0 + raise ArgumentError, 'register_cursor called with cursor_id=0' + end + + @mutex.synchronize do + @active_cursors << id + end end # Unregister a cursor id, indicating that it's no longer active. # # @example Unregister a cursor. @@ -92,10 +97,17 @@ # # @api private # # @since 2.3.0 def unregister_cursor(id) + if id.nil? + raise ArgumentError, 'unregister_cursor called with nil cursor_id' + end + if id == 0 + raise ArgumentError, 'unregister_cursor called with cursor_id=0' + end + @mutex.synchronize do @active_cursors.delete(id) end end @@ -120,15 +132,15 @@ to_kill_copy.each do |server, op_specs| op_specs.each do |op_spec| if server.features.find_command_enabled? Cursor::Builder::KillCursorsCommand.update_cursors(op_spec, active_cursors_copy.to_a) if Cursor::Builder::KillCursorsCommand.get_cursors_list(op_spec).size > 0 - Operation::KillCursors.new(op_spec).execute(server) + Operation::KillCursors.new(op_spec).execute(server, client: nil) end else Cursor::Builder::OpKillCursors.update_cursors(op_spec, active_cursors_copy.to_a) if Cursor::Builder::OpKillCursors.get_cursors_list(op_spec).size > 0 - Operation::KillCursors.new(op_spec).execute(server) + Operation::KillCursors.new(op_spec).execute(server, client: nil) end end end end end