darion-yaphet opened a new pull request, #3590:
URL: https://github.com/apache/brpc/pull/3590

   ### What problem does this PR solve?
   
   Problem Summary:
   
   `Server::StartInternal()` allocates a keytable pool and, when thread-local 
data is configured, a TLS key before the server reaches `RUNNING`. If startup 
fails early—for example, because the requested port is already in 
use—`RevertServerStatus` calls `Stop()` and `Join()`, but both are no-ops 
before `RUNNING`.
   
   As a result, the keytable pool and TLS key were leaked. Retrying `Start()` 
on the same `Server` could overwrite the pool pointer and make the previous 
allocation permanently unreachable. The same leak also affected destruction of 
a server whose startup had failed.
   
   ### What is changed and the side effects?
   
   Changed:
   
   - Add `Server::DestroyPreStartAllocations()` to release the TLS key and 
keytable pool when startup fails before `RUNNING`.
   - Invoke the cleanup from both startup rollback and `Server` destruction.
   - Add a regression test covering port-conflict startup failure, repeated 
failure, and a subsequent successful retry.
   
   Side effects:
   
   - Performance effects: None expected. The cleanup runs only on 
startup-failure paths or destruction of a never-started server.
   - Breaking backward compatibility: None.
   
   ***
   
   ### Check List:
   
   - [x] Changes compile with CMake: `cmake --build build --target 
brpc_server_unittest -j6`
   - [x] Added a regression test.
   - [x] Test passed: `./build/test/brpc_server_unittest 
--gtest_filter=ServerTest.sanity`
   


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