forked from quic-go/quic-go
pass around the stateless reset token directly, not pointers to it
Benchmarks show that it's actually faster to make a copy of this 16 byte array than passing around a pointer to it.
This commit is contained in:
@@ -16,11 +16,11 @@ import (
|
||||
)
|
||||
|
||||
type statelessResetErr struct {
|
||||
token *[16]byte
|
||||
token [16]byte
|
||||
}
|
||||
|
||||
func (e statelessResetErr) Error() string {
|
||||
return fmt.Sprintf("received a stateless reset with token %x", *e.token)
|
||||
return fmt.Sprintf("received a stateless reset with token %x", e.token)
|
||||
}
|
||||
|
||||
// The packetHandlerMap stores packetHandlers, identified by connection ID.
|
||||
@@ -317,7 +317,7 @@ func (h *packetHandlerMap) maybeHandleStatelessReset(data []byte) bool {
|
||||
copy(token[:], data[len(data)-16:])
|
||||
if sess, ok := h.resetTokens[token]; ok {
|
||||
h.logger.Debugf("Received a stateless reset with token %#x. Closing session.", token)
|
||||
go sess.destroy(statelessResetErr{token: &token})
|
||||
go sess.destroy(statelessResetErr{token: token})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user