Closed unext-wendong closed 2 months ago
In the listener mode, it seems if the AcceptFunc returns REJECT, the same request will keep getting accepted, even though the incoming socket has gone.
The following sample code demonstrates the issue:
package main import ( "fmt" "time" srt "github.com/datarhei/gosrt" ) func main() { conf := srt.DefaultConfig() ln, err := srt.Listen("srt", ":6000", conf) if err != nil { fmt.Println("err 1", err) return } for { fmt.Println("Accepting...") conn, mode, err := ln.Accept(func(req srt.ConnRequest) srt.ConnType { // check connection request fmt.Println("Got connection", req.RemoteAddr()) time.Sleep(3 * time.Second) fmt.Println("Rejecting...") return srt.REJECT }) if err != nil { fmt.Println("err 2", err) return } fmt.Println("conn", conn) if mode == srt.REJECT { // rejected connection, ignore continue } fmt.Println("mode", mode) } }
Reproduce procedure:
We observed the following output:
Accepting... Got connection [::1]:65203 Rejecting... conn <nil> Accepting... Got connection [::1]:65203 Rejecting... conn <nil> Accepting... Got connection [::1]:65203 Rejecting... conn <nil> Accepting... Got connection [::1]:65203 Rejecting... conn <nil> Accepting... Got connection [::1]:65203
From what I can tell, it's like it has gone to an endless loop. <-- Not accurate
Sorry, I shouldn't say "endless", it seems to be between 4 to around 12 times.
In the listener mode, it seems if the AcceptFunc returns REJECT, the same request will keep getting accepted, even though the incoming socket has gone.
The following sample code demonstrates the issue:
Reproduce procedure:
We observed the following output: