songgaoye opened a new pull request, #3768:
URL: https://github.com/apache/brpc/pull/3768
### What problem does this PR solve?
Issue Number: N/A
Problem Summary:
Key creation, deletion, and key-table cleanup can concurrently access the
same
key metadata without synchronization. When a key slot is reused while a
thread
exits, cleanup may observe inconsistent version, destructor, and argument
values.
### What is changed and the side effects?
Changed:
- Protect key metadata updates and destructor snapshots with the existing key
mutex.
- Make the key version atomic for the lock-free `bthread_setspecific` check.
- Invoke destructors after releasing the mutex so they can create or delete
keys.
- Add tests for key reuse during thread exit and key recreation in a
destructor.
Side effects:
- Performance effects: Key-table cleanup now acquires the key mutex when it
processes a non-null value. The impact has not been benchmarked.
- Breaking backward compatibility: No API changes.
---
### Check List:
- The new tests passed using an existing local test binary. Rebuilding the
current commit was blocked by a missing macOS SDK in the local
configuration.
- Added regression tests for the concurrency and destructor-reentrancy paths.
- 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]