forked from quic-go/quic-go
small session fixes
This commit is contained in:
13
session.go
13
session.go
@@ -124,6 +124,7 @@ func newSession(conn connection, v protocol.VersionNumber, connectionID protocol
|
|||||||
|
|
||||||
// run the session main loop
|
// run the session main loop
|
||||||
func (s *Session) run() {
|
func (s *Session) run() {
|
||||||
|
// Start the crypto stream handler
|
||||||
go func() {
|
go func() {
|
||||||
if err := s.cryptoSetup.HandleCryptoStream(); err != nil {
|
if err := s.cryptoSetup.HandleCryptoStream(); err != nil {
|
||||||
s.Close(err)
|
s.Close(err)
|
||||||
@@ -139,7 +140,6 @@ func (s *Session) run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the minimum of all timeouts
|
// Calculate the minimum of all timeouts
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
firstTimeout := utils.InfDuration
|
firstTimeout := utils.InfDuration
|
||||||
// Some timeouts are only set when we can actually send
|
// Some timeouts are only set when we can actually send
|
||||||
@@ -304,10 +304,7 @@ func (s *Session) handleStreamFrame(frame *frames.StreamFrame) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) isValidStreamID(streamID protocol.StreamID) bool {
|
func (s *Session) isValidStreamID(streamID protocol.StreamID) bool {
|
||||||
if streamID%2 != 1 {
|
return streamID%2 == 1
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) handleWindowUpdateFrame(frame *frames.WindowUpdateFrame) error {
|
func (s *Session) handleWindowUpdateFrame(frame *frames.WindowUpdateFrame) error {
|
||||||
@@ -357,16 +354,14 @@ func (s *Session) handleRstStreamFrame(frame *frames.RstStreamFrame) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) handleAckFrame(frame *frames.AckFrame) error {
|
func (s *Session) handleAckFrame(frame *frames.AckFrame) error {
|
||||||
|
|
||||||
if err := s.sentPacketHandler.ReceivedAck(frame); err != nil {
|
if err := s.sentPacketHandler.ReceivedAck(frame); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.Debugf("\t<- %#v", frame)
|
utils.Debugf("\t<- %#v", frame)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the connection
|
// Close the connection. If err is nil it will be set to qerr.PeerGoingAway.
|
||||||
func (s *Session) Close(e error) error {
|
func (s *Session) Close(e error) error {
|
||||||
return s.closeImpl(e, false)
|
return s.closeImpl(e, false)
|
||||||
}
|
}
|
||||||
@@ -410,7 +405,7 @@ func (s *Session) closeStreamsWithError(err error) {
|
|||||||
|
|
||||||
// TODO: try sending more than one packet
|
// TODO: try sending more than one packet
|
||||||
func (s *Session) maybeSendPacket() error {
|
func (s *Session) maybeSendPacket() error {
|
||||||
if time.Now().Sub(s.smallPacketDelayedOccurranceTime) > protocol.SmallPacketSendDelay {
|
if !s.smallPacketDelayedOccurranceTime.IsZero() && time.Now().Sub(s.smallPacketDelayedOccurranceTime) > protocol.SmallPacketSendDelay {
|
||||||
return s.sendPacket()
|
return s.sendPacket()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user