Assign DataChannel ID directly to fix conflicts
When opening DataChannels in parallel it was possible
for multiple to be allocated the same ID since the
generateAndSetDataChannelID func references the
DataChannel ID, which was being set after the unlock.
I tested opening 1000 DataChannels at once, and it seems to work perfectly now!
Codecov Report
Merging #2248 (56da953) into master (589d67e) will decrease coverage by
0.14%. The diff coverage is100.00%.
@@ Coverage Diff @@
## master #2248 +/- ##
==========================================
- Coverage 77.43% 77.29% -0.15%
==========================================
Files 87 87
Lines 9197 9195 -2
==========================================
- Hits 7122 7107 -15
- Misses 1642 1654 +12
- Partials 433 434 +1
| Flag | Coverage Δ | |
|---|---|---|
| go | 79.05% <100.00%> (-0.17%) |
:arrow_down: |
| wasm | 70.16% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| datachannel.go | 82.77% <100.00%> (-0.10%) |
:arrow_down: |
| sctptransport.go | 77.90% <0.00%> (-2.63%) |
:arrow_down: |
| dtlstransport.go | 63.04% <0.00%> (-1.87%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 589d67e...56da953. Read the comment docs.
Is it safe to modify d.id without holding the lock? Maybe we could make the id a atomic.Value? Then we drop the unlock and lock