don't negotiate the idle timeout

The idle timeout doesn't need to be negotiated, simply announcing it to
the peer is sufficient. We now close the session if there's no incoming
network activity for the duration of the local idle timeout, and we
send a PING frame after half the remote idle timeout (if keep alives are
enabled).
This commit is contained in:
Marten Seemann
2017-10-02 18:16:27 -07:00
parent 52ed5579f7
commit a8b603b7bf
7 changed files with 53 additions and 90 deletions

View File

@@ -71,11 +71,11 @@ var _ = Describe("Params Negotiator (for gQUIC)", func() {
})
It("sets the connection-level flow control windows in SHLO", func() {
pn.idleConnectionStateLifetime = 0xDECAFBAD * time.Second
pn.idleTimeout = 0xdecafbad * time.Second
entryMap, err := pn.GetHelloMap()
Expect(err).ToNot(HaveOccurred())
Expect(entryMap).To(HaveKey(TagICSL))
Expect(entryMap[TagICSL]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE}))
Expect(entryMap[TagICSL]).To(Equal([]byte{0xad, 0xfb, 0xca, 0xde}))
})
It("sets the negotiated value for maximum streams in the SHLO", func() {
@@ -211,21 +211,8 @@ var _ = Describe("Params Negotiator (for gQUIC)", func() {
})
})
Context("idle connection state lifetime", func() {
It("has initial idle connection state lifetime", func() {
Expect(pn.GetIdleConnectionStateLifetime()).To(Equal(idleTimeout))
})
It("negotiates correctly when the peer wants a longer lifetime", func() {
Expect(pn.negotiateIdleConnectionStateLifetime(idleTimeout + 10*time.Second)).To(Equal(idleTimeout))
})
It("negotiates correctly when the peer wants a shorter lifetime", func() {
Expect(pn.negotiateIdleConnectionStateLifetime(idleTimeout - 3*time.Second)).To(Equal(idleTimeout - 3*time.Second))
})
Context("idle timeout", func() {
It("sets the negotiated lifetime", func() {
// this test only works if the value given here is smaller than protocol.MaxIdleConnectionStateLifetime
values := map[Tag][]byte{
TagICSL: {10, 0, 0, 0},
}
@@ -234,21 +221,6 @@ var _ = Describe("Params Negotiator (for gQUIC)", func() {
Expect(pn.GetIdleConnectionStateLifetime()).To(Equal(10 * time.Second))
})
It("does not change the idle connection state lifetime when given an invalid value", func() {
values := map[Tag][]byte{
TagSFCW: {0xDE, 0xAD, 0xBE}, // 1 byte too short
}
err := pn.SetFromMap(values)
Expect(err).To(MatchError(errMalformedTag))
Expect(pn.GetIdleConnectionStateLifetime()).To(Equal(idleTimeout))
})
It("gets idle connection state lifetime", func() {
value := 0xDECAFBAD * time.Second
pn.idleConnectionStateLifetime = value
Expect(pn.GetIdleConnectionStateLifetime()).To(Equal(value))
})
It("errors when given an invalid value", func() {
values := map[Tag][]byte{TagICSL: {2, 0, 0}} // 1 byte too short
err := pn.SetFromMap(values)