Skip to content

Queue reads everywhere #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 24, 2014
Merged

Queue reads everywhere #144

merged 11 commits into from
Oct 24, 2014

Conversation

mtodd
Copy link
Member

@mtodd mtodd commented Oct 22, 2014

After #138 was merged, I realized that any reads from the socket are susceptible from the same problem as described in #136.

I've added a reproduction (as an integration test) to illustrate the point, and also includes a trivial fix based on replacing read usage with queued_read.

This needs to be done for any usage of read in Net::LDAP::Connection:

  • setup_encryption
  • bind_simple
  • bind_sasl
  • modify
  • add
  • rename
  • delete

cc @jch @schaary

mtodd added 2 commits October 22, 2014 01:26
This is because Net::LDAP::Connection#add calls read without queueing,
meaning it can read the wrong message off the socket.
@jch
Copy link
Member

jch commented Oct 22, 2014

Yup. Let me know when it's ready for review or if you'd like to take a few of the tasks.

@mtodd
Copy link
Member Author

mtodd commented Oct 23, 2014

I was able to come up with a straightforward, if not simpler reproduction of the issue while introducing queued_read-specific unit tests. Still lacks full coverage but it'll be easier to do than the integration test path.

@mtodd
Copy link
Member Author

mtodd commented Oct 24, 2014

FWIW, I'm starting to hate the queued_read method name and would like to rename it.

@jch
Copy link
Member

jch commented Oct 24, 2014

Looks good to me. I didn't try running all of these, but just did a sanity check of the changes.

FWIW, I'm starting to hate the queued_read method name and would like to rename it.

Did you want to just change it back to read now that everything is using it? Something else?

@mtodd
Copy link
Member Author

mtodd commented Oct 24, 2014

@jch read is an option, but that means renaming read to read_socket or something a little more low level, or going with read_message since its responsibility is to return a message matching the message ID.

@jch
Copy link
Member

jch commented Oct 24, 2014

@mtodd your call. I'm fine with leaving it queued_read as is. It's an internal method that's only used within Connection, so it's low impact to change whenever we'd like. 🚢 when you're ready.

@mtodd
Copy link
Member Author

mtodd commented Oct 24, 2014

@jch not going to block this PR on the method name, better to have a separate conversation about it.

mtodd added a commit that referenced this pull request Oct 24, 2014
@mtodd mtodd merged commit 0b73377 into master Oct 24, 2014
@mtodd mtodd deleted the queue-reads-everywhere branch October 24, 2014 19:07
astratto pushed a commit to astratto/ruby-net-ldap that referenced this pull request Dec 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants