panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.83k stars 1.36k forks source link

fix(pool): ensure proper lock handling in retrieveWorker #337

Closed gou-jjjj closed 1 week ago

gou-jjjj commented 2 months ago

Correct the logic for locking the pool in the retrieveWorker function to prevent potential data races and deadlocks. The lock is now deferred until the end of the function, with conditional early unlocks removed. This change simplifies the lock handling and improves the code's readability and correctness.

1. Are you opening this pull request for bug-fixs, optimizations or new feature?

2. Please describe how these code changes achieve your intention.

3. Please link to the relevant issues (if any).

4. Which documentation changes (if any) need to be made/updated because of this PR?

4. Checklist

panjf2000 commented 2 months ago

Does this PR fix any actual issues?

github-actions[bot] commented 2 weeks ago

This PR is marked as stale because it has been open for 21 days with no activity.

You should take one of the following actions:

This PR will be automatically closed in 7 days if no further activity occurs.

github-actions[bot] commented 1 week ago

This PR was closed because it has been inactive for 7 days since being marked as stale.

If you believe this is a false alarm, feel free to reopen this PR or create a new one.