yerixu opened a new pull request, #3296:
URL: https://github.com/apache/brpc/pull/3296

   Socket::SSLHandshake polled the fd via unbounded bthread_fd_wait, so a peer 
that completed the TCP handshake but never sent a TLS Hello (e.g. server not 
actually configured for SSL) parked the handshake bthread forever. That bthread 
holds a Socket reference through the in-flight WriteRequest, so the underlying 
fd was never closed and the connection stayed ESTABLISHED until OS keepalive 
eventually broke it.
   
   Channel destruction does not help: ~Channel only removes the SocketMap ref; 
SetFailed/OnFailed wake _epollout_butex but not the per-fd butex used by 
bthread_fd_wait, and the fd close path runs only after the Socket's ref count 
drops to zero, which the stuck bthread prevents. With a periodic retry, 
ESTABLISHED sockets accumulate without bound.
   
   Switch the two bthread_fd_wait calls in SSLHandshake to 
bthread_fd_timedwait, with the deadline derived from a new gflag 
ssl_handshake_timeout_ms (default 5000ms; <=0 keeps the old behavior).
   On timeout the existing failure path runs: CheckConnected returns -1 ->
   AfterAppConnected calls SetFailed + ReleaseAllFailedWriteRequests, and the 
fd_guard in CheckConnectedAndKeepWrite closes the fd at scope exit. The 
server-side handshake invoked from DoRead benefits from the same bound.
   
   ### What problem does this PR solve?
   
   Issue Number: resolve 
   
   Problem Summary:
   
   ### What is changed and the side effects?
   
   Changed:
   
   Side effects:
   - Performance effects:
   
   - Breaking backward compatibility: 
   
   ---
   ### Check List:
   - Please make sure your changes are compilable.
   - When providing us with a new feature, it is best to add related tests.
   - Please follow [Contributor Covenant Code of 
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
   


-- 
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