Skip to content

Commit

Permalink
http3: fix race condition when creating state tracking stream
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 5, 2024
1 parent 83eeb9c commit ec6b40f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions http3/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ func (c *connection) acceptStream(ctx context.Context) (quic.Stream, *datagramme
}
datagrams := newDatagrammer(func(b []byte) error { return c.sendDatagram(str.StreamID(), b) })
if c.perspective == protocol.PerspectiveServer {
strID := str.StreamID()
c.streamMx.Lock()
c.streams[str.StreamID()] = datagrams
c.streams[strID] = datagrams
c.streamMx.Unlock()
str = newStateTrackingStream(str, func(s streamState, e error) { c.onStreamStateChange(str.StreamID(), s, e) })
str = newStateTrackingStream(str, func(s streamState, e error) { c.onStreamStateChange(strID, s, e) })
}
return str, datagrams, nil
}
Expand Down

0 comments on commit ec6b40f

Please sign in to comment.