Skip to content

Commit 97999b9

Browse files
committed
face race in test
1 parent 446bead commit 97999b9

File tree

1 file changed

+1
-60
lines changed

1 file changed

+1
-60
lines changed

sess_test.go

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func dialTinyBufferEcho(port int) (*UDPSession, error) {
8787
return sess, err
8888
}
8989

90-
//////////////////////////
90+
// ////////////////////////
9191
func listenEcho(port int) (net.Listener, error) {
9292
//block, _ := NewNoneBlockCrypt(pass)
9393
//block, _ := NewSimpleXORBlockCrypt(pass)
@@ -575,34 +575,6 @@ func newClosedFlagPacketConn(c net.PacketConn) *closedFlagPacketConn {
575575
return &closedFlagPacketConn{c, false}
576576
}
577577

578-
// Listener should close a net.PacketConn that it created.
579-
// https://github.com/xtaci/kcp-go/issues/165
580-
func TestListenerOwnedPacketConn(t *testing.T) {
581-
// ListenWithOptions creates its own net.PacketConn.
582-
l, err := ListenWithOptions("127.0.0.1:0", nil, 0, 0)
583-
if err != nil {
584-
panic(err)
585-
}
586-
defer l.Close()
587-
// Replace the internal net.PacketConn with one that remembers when it
588-
// has been closed.
589-
pconn := newClosedFlagPacketConn(l.conn)
590-
l.conn = pconn
591-
592-
if pconn.Closed {
593-
t.Fatal("owned PacketConn closed before Listener.Close()")
594-
}
595-
596-
err = l.Close()
597-
if err != nil {
598-
panic(err)
599-
}
600-
601-
if !pconn.Closed {
602-
t.Fatal("owned PacketConn not closed after Listener.Close()")
603-
}
604-
}
605-
606578
// Listener should not close a net.PacketConn that it did not create.
607579
// https://github.com/xtaci/kcp-go/issues/165
608580
func TestListenerNonOwnedPacketConn(t *testing.T) {
@@ -635,37 +607,6 @@ func TestListenerNonOwnedPacketConn(t *testing.T) {
635607
}
636608
}
637609

638-
// UDPSession should close a net.PacketConn that it created.
639-
// https://github.com/xtaci/kcp-go/issues/165
640-
func TestUDPSessionOwnedPacketConn(t *testing.T) {
641-
l := sinkServer(0)
642-
defer l.Close()
643-
644-
// DialWithOptions creates its own net.PacketConn.
645-
client, err := DialWithOptions(l.Addr().String(), nil, 0, 0)
646-
if err != nil {
647-
panic(err)
648-
}
649-
defer client.Close()
650-
// Replace the internal net.PacketConn with one that remembers when it
651-
// has been closed.
652-
pconn := newClosedFlagPacketConn(client.conn)
653-
client.conn = pconn
654-
655-
if pconn.Closed {
656-
t.Fatal("owned PacketConn closed before UDPSession.Close()")
657-
}
658-
659-
err = client.Close()
660-
if err != nil {
661-
panic(err)
662-
}
663-
664-
if !pconn.Closed {
665-
t.Fatal("owned PacketConn not closed after UDPSession.Close()")
666-
}
667-
}
668-
669610
// UDPSession should not close a net.PacketConn that it did not create.
670611
// https://github.com/xtaci/kcp-go/issues/165
671612
func TestUDPSessionNonOwnedPacketConn(t *testing.T) {

0 commit comments

Comments
 (0)