Fixes second answer dropped (the one carrying the PQ KEM data)

Prevents dropping concurrent answer / offer carrying the PQ ML-KEM data
This commit is contained in:
riccardom
2026-08-04 19:17:44 +02:00
parent f8d58f23e5
commit d2aeb2cc1f
+14 -8
View File
@@ -91,14 +91,20 @@ type Handshaker struct {
func NewHandshaker(log *log.Entry, config ConnConfig, signaler *Signaler, ice *WorkerICE, relay *WorkerRelay, metricsStages *MetricsStages) *Handshaker { func NewHandshaker(log *log.Entry, config ConnConfig, signaler *Signaler, ice *WorkerICE, relay *WorkerRelay, metricsStages *MetricsStages) *Handshaker {
h := &Handshaker{ h := &Handshaker{
log: log, log: log,
config: config, config: config,
signaler: signaler, signaler: signaler,
ice: ice, ice: ice,
relay: relay, relay: relay,
metricsStages: metricsStages, metricsStages: metricsStages,
remoteOffersCh: make(chan OfferAnswer), // Buffered by 1: the single Listen goroutine can be busy handling an offer
remoteAnswerCh: make(chan OfferAnswer), // (sendAnswer does a blocking signal send) exactly when the matching answer
// arrives on the other channel. Unbuffered, that answer would hit the
// non-blocking send's default and be dropped — fatal for the post-quantum
// exchange, which needs the answer to converge. A 1-slot cushion lets it wait
// until Listen loops back, without ever blocking the signal receiver.
remoteOffersCh: make(chan OfferAnswer, 1),
remoteAnswerCh: make(chan OfferAnswer, 1),
} }
// assume remote supports ICE until we learn otherwise from received offers // assume remote supports ICE until we learn otherwise from received offers
h.remoteICESupported.Store(ice != nil) h.remoteICESupported.Store(ice != nil)