pion / dtls

DTLS 1.2 Server/Client implementation for Go
https://pion.ly/
MIT License
604 stars 158 forks source link

Add TestParallelHandshake test case #666

Closed Danielius1922 closed 3 months ago

Danielius1922 commented 3 months ago

Handshake are synchronized by a mutex, but there is a panicing scenario when the first handshake fails.

Description

Reference issue

Fixes #...

Danielius1922 commented 3 months ago

@Sean-Der: The problematic scenario seems to go like this:

Goroutine A: Gets handshake mutex
Goroutine B: Waits on handshake mutex
Goroutine A: Handshake fails
             close(c.decrypted)
Goroutine B: Gets handshake mutex
             Handshake succeeds or fails
             close(c.decrypted)
             panic - closing of a closed channel

If the first handshake succeeds the issue does not occur.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 80.13%. Comparing base (f3e8a9e) to head (38b2704).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #666 +/- ## ========================================== + Coverage 80.05% 80.13% +0.07% ========================================== Files 101 101 Lines 5355 5355 ========================================== + Hits 4287 4291 +4 + Misses 697 694 -3 + Partials 371 370 -1 ``` | [Flag](https://app.codecov.io/gh/pion/dtls/pull/666/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | Coverage Δ | | |---|---|---| | [go](https://app.codecov.io/gh/pion/dtls/pull/666/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | `80.16% <100.00%> (+0.07%)` | :arrow_up: | | [wasm](https://app.codecov.io/gh/pion/dtls/pull/666/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | `64.30% <100.00%> (+0.03%)` | :arrow_up: | 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=pion#carryforward-flags-in-the-pull-request-comment) to find out more.

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