@@ -34,6 +34,11 @@ class CursorReaper
34
34
# @since 2.3.0
35
35
FREQUENCY = 1 . freeze
36
36
37
+ # Symbol for separating parts of scheduled kill spec messages.
38
+ #
39
+ # @api private
40
+ MSG_SEPARATOR = "\t "
41
+
37
42
# Create a cursor reaper.
38
43
#
39
44
# @param [ Cluster ] cluster The cluster.
@@ -63,7 +68,7 @@ def schedule_kill_cursor(kill_spec, server)
63
68
kill_spec . coll_name ,
64
69
kill_spec . db_name ,
65
70
kill_spec . service_id
66
- ] . join ( " \t " )
71
+ ] . join ( MSG_SEPARATOR )
67
72
@pipe_write . puts ( msg )
68
73
end
69
74
@@ -113,10 +118,19 @@ def unregister_cursor(id)
113
118
end
114
119
end
115
120
121
+ # Read and decode scheduled kill cursors operations.
122
+ #
123
+ # This method mutates instance variables without locking, so is is not
124
+ # thread safe. Generally, it should not be called itself, this is a helper
125
+ # for `kill_cursor` method.
126
+ #
127
+ # @api private
116
128
def read_scheduled_kill_specs
117
- while readable_io = IO . select ( [ @pipe_read ] , nil , nil , 0.1 )
118
- msg = readable_io . first [ 0 ] . gets . strip
119
- seed , cursor_id , coll_name , db_name , service_id = msg . split ( "\t " )
129
+ while select_resp = IO . select ( [ @pipe_read ] , nil , nil , 0.1 )
130
+ readable_io = select_resp &.first &.first
131
+ next if readable_io . nil?
132
+ msg = readable_io . gets . strip
133
+ seed , cursor_id , coll_name , db_name , service_id = msg . split ( MSG_SEPARATOR )
120
134
kill_spec = Cursor ::KillSpec . new (
121
135
cursor_id : cursor_id . to_i ,
122
136
coll_name : coll_name ,
0 commit comments