File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -118,23 +118,38 @@ def close
118
118
#
119
119
# Returns a Net::LDAP::PDU object or nil.
120
120
def queued_read ( message_id )
121
- if pdu = ( @queue [ message_id ] || [ ] ) . shift
121
+ if pdu = message_queue [ message_id ] . shift
122
122
return pdu
123
123
end
124
124
125
+ # read messages until we have a match for the given message_id
125
126
while pdu = read
126
127
if pdu . message_id == message_id
127
128
return pdu
128
129
else
129
- @queue [ pdu . message_id ] . push pdu
130
-
130
+ message_queue [ pdu . message_id ] . push pdu
131
131
next
132
132
end
133
133
end
134
134
135
135
pdu
136
136
end
137
137
138
+ # Internal: The internal queue of messages, read from the socket, grouped by
139
+ # message ID.
140
+ #
141
+ # Used by `queued_read` to return messages sent by the server with the given
142
+ # ID. If no messages are queued for that ID, `queued_read` will `read` from
143
+ # the socket and queue messages that don't match the given ID for other
144
+ # readers.
145
+ #
146
+ # Returns the message queue Hash.
147
+ def message_queue
148
+ @message_queue ||= Hash . new do |hash , key |
149
+ hash [ key ] = [ ]
150
+ end
151
+ end
152
+
138
153
# Internal: Reads and parses data from the configured connection.
139
154
#
140
155
# - syntax: the BER syntax to use to parse the read data with
@@ -380,9 +395,7 @@ def search(args = {})
380
395
result_pdu = nil
381
396
n_results = 0
382
397
383
- @queue ||= { }
384
398
message_id = next_msgid
385
- @queue [ message_id ] ||= [ ]
386
399
387
400
instrument "search.net_ldap_connection" ,
388
401
:message_id => message_id ,
You can’t perform that action at this time.
0 commit comments