darion-yaphet opened a new pull request, #3638: URL: https://github.com/apache/brpc/pull/3638
### What problem does this PR solve? Issue Number: N/A Problem Summary: `borrow_keytable()` reads `pool->list` and `pool->free_keytables` before acquiring the pool lock. These reads race with writes during pool destruction and other pool operations. ### What is changed and the side effects? Changed: - Read pool pointers and the destroyed state under the existing rwlock. - Keep only a boolean availability hint between the read and write lock sections, then recheck the pool state under the write lock. - Add coverage for concurrent borrowing, returning, and pool destruction, including reclamation of tables returned after destruction. Side effects: - Performance effects: Reuses the existing locking on the live-pool borrowing path. Borrowing from a destroyed pool now also acquires the read lock. Performance benchmarks were not run. - Breaking backward compatibility: None. No public API or data layout changes. --- ### Check List: - [x] Build passed: `cmake --build build --target bthread_key_unittest -j6`. - [x] All 11 `KeyTest` tests passed. - [x] The new concurrent destruction test passed 100 repetitions. - TSan was not run; repeated test success alone does not prove the absence of data races. - 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]
