Felix-Gong commented on code in PR #3316:
URL: https://github.com/apache/brpc/pull/3316#discussion_r3328169537


##########
src/brpc/socket.cpp:
##########
@@ -2133,11 +2133,19 @@ 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);
             errno = ESSL;
+            return -1;

Review Comment:
   You're right. No changes are needed for this branch — the real fix is only 
in the if (nr == 0) branch where the original code fell through and returned 0 
without distinguishing unexpected SSL EOF from a clean shutdown. I'll revert 
this change.



##########
src/brpc/socket.cpp:
##########
@@ -2146,6 +2154,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) {

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to