@@ -1892,7 +1892,6 @@ var _ = Describe("Connection", func() {
18921892
18931893 It ("cancels the HandshakeComplete context when the handshake completes" , func () {
18941894 packer .EXPECT ().PackCoalescedPacket (false , gomock .Any (), conn .version ).AnyTimes ()
1895- finishHandshake := make (chan struct {})
18961895 sph := mockackhandler .NewMockSentPacketHandler (mockCtrl )
18971896 conn .sentPacketHandler = sph
18981897 tracer .EXPECT ().DroppedEncryptionLevel (protocol .EncryptionHandshake )
@@ -1902,53 +1901,26 @@ var _ = Describe("Connection", func() {
19021901 sph .EXPECT ().DropPackets (protocol .EncryptionHandshake )
19031902 sph .EXPECT ().SetHandshakeConfirmed ()
19041903 connRunner .EXPECT ().Retire (clientDestConnID )
1905- go func () {
1906- defer GinkgoRecover ()
1907- <- finishHandshake
1908- cryptoSetup .EXPECT ().StartHandshake ()
1909- cryptoSetup .EXPECT ().NextEvent ().Return (handshake.Event {Kind : handshake .EventHandshakeComplete })
1910- cryptoSetup .EXPECT ().NextEvent ().Return (handshake.Event {Kind : handshake .EventNoEvent })
1911- cryptoSetup .EXPECT ().SetHandshakeConfirmed ()
1912- cryptoSetup .EXPECT ().GetSessionTicket ()
1913- conn .run ()
1914- }()
1904+ cryptoSetup .EXPECT ().SetHandshakeConfirmed ()
1905+ cryptoSetup .EXPECT ().GetSessionTicket ()
19151906 handshakeCtx := conn .HandshakeComplete ()
19161907 Consistently (handshakeCtx ).ShouldNot (BeClosed ())
1917- close ( finishHandshake )
1908+ Expect ( conn . handleHandshakeComplete ()). To ( Succeed () )
19181909 Eventually (handshakeCtx ).Should (BeClosed ())
1919- // make sure the go routine returns
1920- streamManager .EXPECT ().CloseWithError (gomock .Any ())
1921- expectReplaceWithClosed ()
1922- packer .EXPECT ().PackApplicationClose (gomock .Any (), gomock .Any (), conn .version ).Return (& coalescedPacket {buffer : getPacketBuffer ()}, nil )
1923- cryptoSetup .EXPECT ().Close ()
1924- mconn .EXPECT ().Write (gomock .Any (), gomock .Any ())
1925- tracer .EXPECT ().ClosedConnection (gomock .Any ())
1926- tracer .EXPECT ().Close ()
1927- conn .shutdown ()
1928- Eventually (conn .Context ().Done ()).Should (BeClosed ())
19291910 })
19301911
19311912 It ("sends a session ticket when the handshake completes" , func () {
19321913 const size = protocol .MaxPostHandshakeCryptoFrameSize * 3 / 2
19331914 packer .EXPECT ().PackCoalescedPacket (false , gomock .Any (), conn .version ).AnyTimes ()
1934- finishHandshake := make (chan struct {})
19351915 connRunner .EXPECT ().Retire (clientDestConnID )
19361916 conn .sentPacketHandler .DropPackets (protocol .EncryptionInitial )
19371917 tracer .EXPECT ().DroppedEncryptionLevel (protocol .EncryptionHandshake )
1938- go func () {
1939- defer GinkgoRecover ()
1940- <- finishHandshake
1941- cryptoSetup .EXPECT ().StartHandshake ()
1942- cryptoSetup .EXPECT ().NextEvent ().Return (handshake.Event {Kind : handshake .EventHandshakeComplete })
1943- cryptoSetup .EXPECT ().NextEvent ().Return (handshake.Event {Kind : handshake .EventNoEvent })
1944- cryptoSetup .EXPECT ().SetHandshakeConfirmed ()
1945- cryptoSetup .EXPECT ().GetSessionTicket ().Return (make ([]byte , size ), nil )
1946- conn .run ()
1947- }()
1918+ cryptoSetup .EXPECT ().SetHandshakeConfirmed ()
1919+ cryptoSetup .EXPECT ().GetSessionTicket ().Return (make ([]byte , size ), nil )
19481920
19491921 handshakeCtx := conn .HandshakeComplete ()
19501922 Consistently (handshakeCtx ).ShouldNot (BeClosed ())
1951- close ( finishHandshake )
1923+ Expect ( conn . handleHandshakeComplete ()). To ( Succeed () )
19521924 var frames []ackhandler.Frame
19531925 Eventually (func () []ackhandler.Frame {
19541926 frames , _ = conn .framer .AppendControlFrames (nil , protocol .MaxByteCount , protocol .Version1 )
@@ -1964,16 +1936,6 @@ var _ = Describe("Connection", func() {
19641936 }
19651937 }
19661938 Expect (size ).To (BeEquivalentTo (s ))
1967- // make sure the go routine returns
1968- streamManager .EXPECT ().CloseWithError (gomock .Any ())
1969- expectReplaceWithClosed ()
1970- packer .EXPECT ().PackApplicationClose (gomock .Any (), gomock .Any (), conn .version ).Return (& coalescedPacket {buffer : getPacketBuffer ()}, nil )
1971- cryptoSetup .EXPECT ().Close ()
1972- mconn .EXPECT ().Write (gomock .Any (), gomock .Any ())
1973- tracer .EXPECT ().ClosedConnection (gomock .Any ())
1974- tracer .EXPECT ().Close ()
1975- conn .shutdown ()
1976- Eventually (conn .Context ().Done ()).Should (BeClosed ())
19771939 })
19781940
19791941 It ("doesn't cancel the HandshakeComplete context when the handshake fails" , func () {
@@ -2028,6 +1990,7 @@ var _ = Describe("Connection", func() {
20281990 cryptoSetup .EXPECT ().SetHandshakeConfirmed ()
20291991 cryptoSetup .EXPECT ().GetSessionTicket ()
20301992 mconn .EXPECT ().Write (gomock .Any (), gomock .Any ())
1993+ Expect (conn .handleHandshakeComplete ()).To (Succeed ())
20311994 conn .run ()
20321995 }()
20331996 Eventually (done ).Should (BeClosed ())
@@ -2351,6 +2314,7 @@ var _ = Describe("Connection", func() {
23512314 cryptoSetup .EXPECT ().NextEvent ().Return (handshake.Event {Kind : handshake .EventNoEvent })
23522315 cryptoSetup .EXPECT ().GetSessionTicket ().MaxTimes (1 )
23532316 cryptoSetup .EXPECT ().SetHandshakeConfirmed ().MaxTimes (1 )
2317+ Expect (conn .handleHandshakeComplete ()).To (Succeed ())
23542318 err := conn .run ()
23552319 nerr , ok := err .(net.Error )
23562320 Expect (ok ).To (BeTrue ())
@@ -2868,7 +2832,10 @@ var _ = Describe("Client Connection", func() {
28682832 TransportParameters : params ,
28692833 })
28702834 cryptoSetup .EXPECT ().NextEvent ().Return (handshake.Event {Kind : handshake .EventHandshakeComplete }).MaxTimes (1 )
2871- cryptoSetup .EXPECT ().NextEvent ().Return (handshake.Event {Kind : handshake .EventNoEvent }).MaxTimes (1 )
2835+ cryptoSetup .EXPECT ().NextEvent ().Return (handshake.Event {Kind : handshake .EventNoEvent }).MaxTimes (1 ).Do (func () {
2836+ defer GinkgoRecover ()
2837+ Expect (conn .handleHandshakeComplete ()).To (Succeed ())
2838+ })
28722839 errChan <- conn .run ()
28732840 close (errChan )
28742841 }()
0 commit comments