trpc-group / trpc-go

A pluggable, high-performance RPC framework written in golang
Other
743 stars 85 forks source link

{stream,transport}: fix connection overwriting when a client uses the same port to connect. #131

Closed Leoyoungxh closed 8 months ago

Leoyoungxh commented 8 months ago

The server's transport maintains an addrToConn map based only on the client's IP-Port. When a client connects to different ports on the server using the same local IP-port, it causes the connections in the server transport's addrToConn map to be overwritten, leading to a "Can't find conn by addr" error in the streaming service.

So now, the combination of the client's IP-Port and the server's IP-Port is used as the addrToConn map key.

codecov[bot] commented 8 months ago

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (369c60d) 85.60258% compared to head (96c35b6) 85.46797%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #131 +/- ## =================================================== - Coverage 85.60258% 85.46797% -0.13462% =================================================== Files 188 189 +1 Lines 16114 16123 +9 =================================================== - Hits 13794 13780 -14 - Misses 1755 1785 +30 + Partials 565 558 -7 ``` | [Flag](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group) | `85.46797% <87.50000%> (-0.13462%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group) | Coverage Δ | | |---|---|---| | [codec\_stream.go](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group#diff-Y29kZWNfc3RyZWFtLmdv) | `83.97626% <100.00000%> (ø)` | | | [internal/addrutil/addrutil.go](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group#diff-aW50ZXJuYWwvYWRkcnV0aWwvYWRkcnV0aWwuZ28=) | `100.00000% <100.00000%> (ø)` | | | [stream/server.go](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group#diff-c3RyZWFtL3NlcnZlci5nbw==) | `82.60870% <100.00000%> (-3.55483%)` | :arrow_down: | | [transport/server\_transport\_tcp.go](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group#diff-dHJhbnNwb3J0L3NlcnZlcl90cmFuc3BvcnRfdGNwLmdv) | `77.11864% <100.00000%> (ø)` | | | [transport/tnet/server\_transport\_tcp.go](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group#diff-dHJhbnNwb3J0L3RuZXQvc2VydmVyX3RyYW5zcG9ydF90Y3AuZ28=) | `72.89720% <100.00000%> (ø)` | | | [transport/server\_transport\_stream.go](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group#diff-dHJhbnNwb3J0L3NlcnZlcl90cmFuc3BvcnRfc3RyZWFtLmdv) | `61.29032% <85.71429%> (+1.91532%)` | :arrow_up: | | [transport/tnet/server\_transport.go](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group#diff-dHJhbnNwb3J0L3RuZXQvc2VydmVyX3RyYW5zcG9ydC5nbw==) | `84.61538% <72.72727%> (-0.51977%)` | :arrow_down: | ... and [6 files with indirect coverage changes](https://app.codecov.io/gh/trpc-group/trpc-go/pull/131/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trpc-group)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.