Repository navigation
Conversation
SSL_get_error() only reports SSL_ERROR_WANT_READ/WANT_WRITE reliably if the thread's error queue is empty before the I/O call. A stale entry, for example the 'unexpected eof while reading' left behind when a server drops another connection without close_notify, made a non-blocking read that simply had no data yet fail with REDIS_ERR_IO. Clear the queue before SSL_read() and SSL_write(), as redisSSLConnect() already does before SSL_connect(), and add a regression test. Fixes redis#1389
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1389.
redisSSLRead()andredisSSLWrite()callSSL_get_error()afterSSL_read()/SSL_write()without clearing the thread's OpenSSL error queue first. If something is already on the queue (for example the "unexpected eof while reading" left behind when another connection was dropped withoutclose_notify),SSL_get_error()returnsSSL_ERROR_SSL/SSL_ERROR_SYSCALLinstead ofSSL_ERROR_WANT_READ, and a non-blocking read that just has no data yet fails withREDIS_ERR_IO.This adds
ERR_clear_error()before both calls, the same wayredisSSLConnect()already does beforeSSL_connect().There's a new SSL test that does a round trip on a connection, switches it to non-blocking, puts an error on the queue and calls
redisBufferRead(). CMake needsOpenSSL::Cryptoonhiredis-testfor that, since the test calls libcrypto directly.Testing (Debian, OpenSSL 3.5.7, redis-server 8.0.2):
make USE_SSL=1 check: all tests pass; with thessl.cchange reverted the new test fails.-DENABLE_SSL=ON -DENABLE_SSL_TESTS=ONplusTEST_SSL=1 ./test.sh: all tests pass.repro.cfrom the issue:plantedanddropnow returnREDIS_OKfor connection B (before: "Resource temporarily unavailable");controlanddrop-clearunchanged.Note
Medium Risk
Changes TLS I/O error handling on every SSL read/write; behavior is narrowly scoped but affects connection reliability for non-blocking and multi-connection workloads.
Overview
Fixes incorrect I/O errors on non-blocking TLS reads/writes when the thread’s OpenSSL error queue already holds stale entries (e.g. from a prior connection).
redisSSLRead()andredisSSLWrite()now callERR_clear_error()beforeSSL_read/SSL_write, matchingredisSSLConnect(), soSSL_get_error()can returnWANT_READ/WANT_WRITEinstead ofSSL_ERROR_SSL.Adds a non-Windows SSL regression test that plants a fake queue entry and asserts
redisBufferRead()staysREDIS_OKon an idle non-blocking connection. CMake linksOpenSSL::Cryptointohiredis-testwhen SSL tests are enabled so the test can use libcrypto APIs directly.Reviewed by Cursor Bugbot for commit a1d3b8f. Bugbot is set up for automated code reviews on this repo. Configure here.