Closed
Description
What version of Go are you using (go version
)?
$ go version > go1.13.4 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
Ubuntu 18.04.2 LTS | Kernel version: 4.15.0-66-generic
What did you do?
This function is called as a gorutine:
// Listens infinitely for UDP packet arrivals and
// executes it's processing inside a gorutine.
func startUDPListener(netw string, router *Router) {
lAddr := getLocalIPAddress()
// Set listening port.
lAddr.Port = int(router.myPeerInfo.port)
PacketConnCreation:
// listen to incoming udp packets
pc, err := net.ListenUDP(netw, &lAddr)
if err != nil {
log.Panic(err)
}
// Set initial deadline.
pc.SetReadDeadline(time.Now().Add(time.Minute))
for {
//simple read
buffer := make([]byte, 1024)
byteNum, uAddr, err := pc.ReadFromUDP(buffer)
if err != nil {
// If we get an error, we just close the pc and create a new one.
log.Printf("%v", err)
pc.Close()
goto PacketConnCreation
} else {
// Set a new deadline for the connection.
pc.SetReadDeadline(time.Now().Add(5 * time.Minute))
go processPacket(*uAddr, byteNum, buffer, router)
}
}
}
What did you expect to see?
I was expecting ReadFromUDP
to ALWAYS return an error if the DeadLine is crossed and I don't recieve any UDP packet on my IP:Port
interface before this happens.
What did you see instead?
Instead of that, it sometimes hangs completely without giving any kind of errors.
It's completely random, it sometimes hangs and sometimes doesn't (providing the corresponding i/o timeout)
It just stays running forever without accepting new packets (or even reading them). The gorutine gets completely freezed (or at least it seems so).