Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/brpc/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,14 @@ ssize_t Socket::DoRead(size_t size_hint) {
default: {
const unsigned long e = ERR_get_error();
if (nr == 0) {
// Socket EOF or SSL session EOF
if (ssl_error != SSL_ERROR_ZERO_RETURN) {
// Unexpected EOF without proper SSL shutdown (close_notify)
LOG(WARNING) << "Fail to read from ssl_fd=" << fd()
<< ": unexpected ssl_error=" << ssl_error;
errno = ESSL;
return -1;
}
// Clean SSL shutdown (close_notify received)
} else if (e != 0) {
LOG(WARNING) << "Fail to read from ssl_fd=" << fd()
<< ": " << SSLError(e);
Expand All @@ -2146,6 +2153,10 @@ ssize_t Socket::DoRead(size_t size_hint) {
BIO_fd_non_fatal_error(saved_errno) != 0 ||
nr < 0;
PLOG_IF(WARNING, is_fatal_error) << "Fail to read from ssl_fd=" << fd();
if (is_fatal_error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why modify this branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is changing errno from saved_errno to ESSL, which is a minor semantic improvement but not a bug fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change this behavior, you'd better check the callers' code and make sure they don't depend on the value of errno.

errno = ESSL;
return -1;
}
errno = saved_errno;
}
break;
Expand Down
Loading