Skip to content
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

Bring Socket::SSL#readbyte in line with Socket / IO#readbyte #700

Merged
merged 2 commits into from
Oct 8, 2015

Conversation

niels
Copy link
Contributor

@niels niels commented Oct 8, 2015

IO#readbyte – and thus Mongo::Socket#readbyte – behave as follows:

  1. Return the next 8-bit byte (0..255) as an Integer if data is present.
  2. Raise EOFError if EOF was reached before then.

Mongo::Socket::SSL overrides this to simply call OpenSSL::Buffering resp. IO#read which behave markedly different:

  1. Return the String representation of the first 8-bit byte if data is present.
  2. Return nil if EOF was reached before then.

This patch brings Mongo::Socker::SSL#readbyte in line with IO#readbyte thus unifying #readbyte behaviour across all socket types in this driver.

The difference in behaviour between SSL and non-SSL connections led to bugs such as https://jira.mongodb.org/browse/RUBY-1048. Also see mongodb/bson-ruby#44 for a previous workaround for a specific edge-case. This patch however fixes the root cause.

by returning an Integer byte rather than a String and raising EOFError
if EOF was reached.

This unifies #readbyte across SSL and non-SSL connections.

[also see mongodb/bson-ruby#44]
durran added a commit that referenced this pull request Oct 8, 2015
Bring Socket::SSL#readbyte in line with Socket / IO#readbyte
@durran durran merged commit d5fa68d into mongodb:master Oct 8, 2015
@niels niels deleted the unify-socket-data branch October 8, 2015 16:57
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