vapor / postgres-nio

🐘 Non-blocking, event-driven Swift client for PostgreSQL.
https://api.vapor.codes/postgresnio/documentation/postgresnio/
MIT License
323 stars 75 forks source link

Crash fix: Multiple bad messages could trigger reentrancy issue #379

Closed fabianfett closed 1 year ago

fabianfett commented 1 year ago

If we receive multiple unexpected messages from the backend we can run into a reentrency situation in which we still have unread messages in the incomming buffer after we have received channelInactive. This pr patches this crash.

Fixes the crash mentioned in #374.

codecov-commenter commented 1 year ago

Codecov Report

Merging #379 (39c5d72) into main (f3587a5) will increase coverage by 0.09%. The diff coverage is 67.16%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #379 +/- ## ========================================== + Coverage 44.35% 44.44% +0.09% ========================================== Files 118 118 Lines 8630 8639 +9 ========================================== + Hits 3828 3840 +12 + Misses 4802 4799 -3 ``` | [Files Changed](https://app.codecov.io/gh/vapor/postgres-nio/pull/379?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [...nection State Machine/ConnectionStateMachine.swift](https://app.codecov.io/gh/vapor/postgres-nio/pull/379?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9Qb3N0Z3Jlc05JTy9OZXcvQ29ubmVjdGlvbiBTdGF0ZSBNYWNoaW5lL0Nvbm5lY3Rpb25TdGF0ZU1hY2hpbmUuc3dpZnQ=) | `56.33% <66.66%> (+0.65%)` | :arrow_up: | | [...urces/PostgresNIO/New/PostgresChannelHandler.swift](https://app.codecov.io/gh/vapor/postgres-nio/pull/379?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9Qb3N0Z3Jlc05JTy9OZXcvUG9zdGdyZXNDaGFubmVsSGFuZGxlci5zd2lmdA==) | `61.05% <67.27%> (+0.07%)` | :arrow_up: |