1
0
mirror of https://github.com/golang/go synced 2024-11-25 10:17:57 -07:00

net: panic if sockaddrToTCP returns nil incorrectly

Part of diagnosing the selfConnect bug
TBR=dsymonds

R=golang-dev
CC=golang-dev
https://golang.org/cl/5687057
This commit is contained in:
Rob Pike 2012-02-21 15:21:34 +11:00
parent 2155a0408e
commit 3970d2fd58

View File

@ -9,6 +9,7 @@
package net package net
import ( import (
"fmt"
"io" "io"
"os" "os"
"syscall" "syscall"
@ -26,6 +27,12 @@ func sockaddrToTCP(sa syscall.Sockaddr) Addr {
return &TCPAddr{sa.Addr[0:], sa.Port} return &TCPAddr{sa.Addr[0:], sa.Port}
case *syscall.SockaddrInet6: case *syscall.SockaddrInet6:
return &TCPAddr{sa.Addr[0:], sa.Port} return &TCPAddr{sa.Addr[0:], sa.Port}
default:
if sa != nil {
// TODO(r): Diagnose when we will turn a non-nil sockaddr into a nil.
// Part of diagnosing the selfConnect bug.
panic(fmt.Sprintf("unexpected type in sockaddrToTCP: %T", sa))
}
} }
return nil return nil
} }