anacrolix / utp

Use anacrolix/go-libutp instead
https://github.com/anacrolix/go-libutp
Mozilla Public License 2.0
173 stars 35 forks source link

Setting deadlines on a connection panics #10

Closed AudriusButkevicius closed 8 years ago

AudriusButkevicius commented 8 years ago

I guess this relies on the socket having had at least a single connection?

package main

import(
    "time"

    "github.com/anacrolix/utp"
)

func main() {
    s, err := utp.NewSocket("udp", ":0")
    if err == nil {
        s.SetReadDeadline(time.Now().Add(time.Second))
    }
}
panic: deadline callback is nil

goroutine 1 [running]:
panic(0x6f3120, 0xc08200af40)
    C:/Go/src/runtime/panic.go:464 +0x3f4
github.com/anacrolix/utp.(*deadlineCallback).updateTimer(0xc0820ae078)
    C:/Go/bin/src/github.com/anacrolix/utp/utp.go:89 +0xde
github.com/anacrolix/utp.(*deadlineCallback).setDeadline(0xc0820ae078, 0xeceae9880, 0x24eb8a24, 0x9dd8a0)
    C:/Go/bin/src/github.com/anacrolix/utp/utp.go:96 +0x4e
github.com/anacrolix/utp.(*connDeadlines).SetReadDeadline(0xc0820ae078, 0xeceae9880, 0x24eb8a24, 0x9dd8a0, 0x0, 0x0)
    C:/Go/bin/src/github.com/anacrolix/utp/utp.go:116 +0x57
main.main()
    C:/Users/Audrius/AppData/Local/liteide/goplay.go:12 +0x14a
exit status 2
anacrolix commented 8 years ago

No it's just some lost behaviour during an earlier cleanup of mutexes and conditions. Thanks for the catch. I've added a test and tidied it up.