Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it thread safe in the use of play? #19

Closed
hy05190134 opened this issue Apr 12, 2016 · 14 comments
Closed

is it thread safe in the use of play? #19

hy05190134 opened this issue Apr 12, 2016 · 14 comments

Comments

@hy05190134
Copy link
Contributor

I use rtmp client to check the edge ip whether can be fetch data?

func DetectRtmp(vip string) bool {
rtmpName := "rtmp://" + vip + "/uplive.b0.upaiyun.com/live"
streamName := "jiqiang"

//fmt.Printf("%s\n", rtmp_name)
createStreamChan := make(chan rtmp.OutboundStream)
var audioSize int64 = 0
var videoSize int64 = 0
testHandler := &TestOutboundConnHandler{createStreamChan, &audioSize, &videoSize}
//tcp dial
obConn, err := rtmp.Dial(rtmpName, testHandler, 100)
if err != nil {
    //fmt.Printf("%s dial fail, err: %s\n", vip, err.Error())
    return false
}
defer obConn.Close()

//rtmp conn
if err = obConn.Connect(); err != nil {
    //fmt.Printf("%s conn fail, err: %s\n", vip, err.Error())
    return false
}

flag := true
count := 0
for {
    select {
    case stream := <-createStreamChan:
        // Play
        err = stream.Play(streamName, nil, nil, nil)
        if err != nil {
            //fmt.Printf("Play error: %s", err.Error())
            flag = false
        }
        // Set Buffer Length

    case <-time.After(1 * time.Second):
        if audioSize > 0 || videoSize > 0 {
            //fmt.Printf("Audio size: %d bytes; Vedio size: %d bytes\n", audioSize, videoSize)
        } else {
            count += 1
        }
    }

    if count > delay || !flag {
        flag = false
        break
    } else if audioSize > 0 || videoSize > 0 {
        break
    }
}

return flag

}

func Check() {
res := make(map[string]bool)
var wg sync.WaitGroup
var mutex = &sync.Mutex{}

for name, ip := range edgeList {
    wg.Add(1)
    // one go routine to handle one check
    go func(name string, ip string) {
        defer wg.Done()
        mutex.Lock()
        res[name] = false
        mutex.Unlock()
        v := DetectRtmp(ip)
        if !v {
            v = DetectRtmp(ip)
        }
        mutex.Lock()
        res[name] = v
        mutex.Unlock()
    }(name, ip)
}

wg.Wait()

fmt.Println("handle all vips")
gMutex.Lock()
for k, v := range res {
    gRes[k] = v
}
gMutex.Unlock()

}

WARNING: DATA RACE
Write by goroutine 420:
github.com/zhangpeihao/gortmp.(_conn).Close()
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/conn.go:444 +0x3a
github.com/zhangpeihao/gortmp.(_outboundConn).Close.func1()
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:249 +0x70

Previous read by goroutine 73:
github.com/zhangpeihao/gortmp.(*conn).sendLoop()
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/conn.go:241 +0x79

Goroutine 420 (running) created at:
github.com/zhangpeihao/gortmp.(*outboundConn).Close()
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:250 +0x15c
main.DetectRtmp()
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:101 +0x4c3
main.Check.func1()
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:117 +0xca

Goroutine 73 (running) created at:
github.com/zhangpeihao/gortmp.NewConn()
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/conn.go:148 +0x71c
github.com/zhangpeihao/gortmp.Dial()
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:109 +0xabd
main.DetectRtmp()
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:59 +0x25a
main.Check.func1()
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:117 +0xca

@hy05190134
Copy link
Contributor Author

and I find it will run into the state of deadlock , then I send the quit signal and it dump the text below:

goroutine 0 [idle]:
runtime.futex(0x90d4f0, 0x0, 0x0, 0x0, 0x0, 0x90cb00, 0x0, 0x0, 0x40f984, 0x90d4f0, ...)
/usr/lib/golang/src/runtime/sys_linux_amd64.s:288 +0x21
runtime.futexsleep(0x90d4f0, 0x0, 0xffffffffffffffff)
/usr/lib/golang/src/runtime/os1_linux.go:39 +0x53
runtime.notesleep(0x90d4f0)
/usr/lib/golang/src/runtime/lock_futex.go:142 +0xa4
runtime.stopm()
/usr/lib/golang/src/runtime/proc1.go:1128 +0x112
runtime.findrunnable(0xc82001f500, 0x0)
/usr/lib/golang/src/runtime/proc1.go:1530 +0x69e
runtime.schedule()
/usr/lib/golang/src/runtime/proc1.go:1639 +0x267
runtime.goschedImpl(0xc820000f00)
/usr/lib/golang/src/runtime/proc1.go:1713 +0x12a
runtime.gosched_m(0xc820000f00)
/usr/lib/golang/src/runtime/proc1.go:1721 +0x32
runtime.mcall(0x7fff8e9fbc70)
/usr/lib/golang/src/runtime/asm_amd64.s:204 +0x5b

goroutine 1 [IO wait]:
net.runtime_pollWait(0x7ff70fa2f508, 0x72, 0xc8200660a0)
/usr/lib/golang/src/runtime/netpoll.go:157 +0x60
net.(_pollDesc).Wait(0xc8200ca060, 0x72, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x3a
net.(_pollDesc).WaitRead(0xc8200ca060, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x36
net.(_netFD).accept(0xc8200ca000, 0x0, 0x7ff70fa2f600, 0xc8200d1580)
/usr/lib/golang/src/net/fd_unix.go:408 +0x27c
net.(_TCPListener).AcceptTCP(0xc820076020, 0x452720, 0x0, 0x0)
/usr/lib/golang/src/net/tcpsock_posix.go:254 +0x4d
net/http.tcpKeepAliveListener.Accept(0xc820076020, 0x0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/http/server.go:2135 +0x41
net/http.(_Server).Serve(0xc8200620c0, 0x7ff70fa2f5c8, 0xc820076020, 0x0, 0x0)
/usr/lib/golang/src/net/http/server.go:1887 +0xb3
net/http.(_Server).ListenAndServe(0xc8200620c0, 0x0, 0x0)
/usr/lib/golang/src/net/http/server.go:1877 +0x136
net/http.ListenAndServe(0x76ace0, 0x5, 0x0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/http/server.go:1967 +0x8f
main.main()
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:333 +0x16a

goroutine 17 [syscall, 73 minutes, locked to thread]:
runtime.goexit()
/usr/lib/golang/src/runtime/asm_amd64.s:1696 +0x1

goroutine 19 [semacquire, 25 minutes]:
sync.runtime_Semacquire(0xc820aa4edc)
/usr/lib/golang/src/runtime/sema.go:43 +0x26
sync.(*WaitGroup).Wait(0xc820aa4ed0)
/usr/lib/golang/src/sync/waitgroup.go:126 +0xb4
main.Check()
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:127 +0x1e6
main.CheckAll()
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:139 +0x18
created by main.main
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:330 +0x120

goroutine 1944 [IO wait, 8 minutes]:
net.runtime_pollWait(0x7ff70fa31af8, 0x72, 0xc8200660a0)
/usr/lib/golang/src/runtime/netpoll.go:157 +0x60
net.(_pollDesc).Wait(0xc8212460d0, 0x72, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x3a
net.(_pollDesc).WaitRead(0xc8212460d0, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x36
net.(_netFD).Read(0xc821246070, 0xc82029d000, 0x1000, 0x1000, 0x0, 0x7ff70fa2a028, 0xc8200660a0)
/usr/lib/golang/src/net/fd_unix.go:232 +0x23a
net.(_conn).Read(0xc820076030, 0xc82029d000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/net.go:172 +0xe4
bufio.(_Reader).fill(0xc8202f0120)
/usr/lib/golang/src/bufio/bufio.go:97 +0x1e9
bufio.(_Reader).ReadByte(0xc8202f0120, 0x0, 0x0, 0x0)
/usr/lib/golang/src/bufio/bufio.go:229 +0x7a
github.com/zhangpeihao/gortmp.Handshake(0x7ff70fa2f670, 0xc820076030, 0xc8202f0120, 0xc82024e040, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/handshake.go:207 +0x622
github.com/zhangpeihao/gortmp.Dial(0xc8210280c0, 0x2e, 0x7ff70fa2f628, 0xc820700260, 0x64, 0x0, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:96 +0x53f
main.DetectRtmp(0x770ff0, 0xc, 0xc82012b700)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:59 +0x1eb
main.Check.func1(0xc820aa4ed0, 0xc820aa4ee0, 0xc820d55e30, 0x771c10, 0xb, 0x770ff0, 0xc)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:119 +0xe3
created by main.Check
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:124 +0x1b4

goroutine 2051 [IO wait, 8 minutes]:
net.runtime_pollWait(0x7ff70fa32f18, 0x72, 0xc8200660a0)
/usr/lib/golang/src/runtime/netpoll.go:157 +0x60
net.(_pollDesc).Wait(0xc8200ca1b0, 0x72, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x3a
net.(_pollDesc).WaitRead(0xc8200ca1b0, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x36
net.(_netFD).Read(0xc8200ca150, 0xc820877000, 0x1000, 0x1000, 0x0, 0x7ff70fa2a028, 0xc8200660a0)
/usr/lib/golang/src/net/fd_unix.go:232 +0x23a
net.(_conn).Read(0xc820076050, 0xc820877000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/net.go:172 +0xe4
bufio.(_Reader).fill(0xc8202f06c0)
/usr/lib/golang/src/bufio/bufio.go:97 +0x1e9
bufio.(_Reader).ReadByte(0xc8202f06c0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/bufio/bufio.go:229 +0x7a
github.com/zhangpeihao/gortmp.Handshake(0x7ff70fa2f670, 0xc820076050, 0xc8202f06c0, 0xc82024e140, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/handshake.go:207 +0x622
github.com/zhangpeihao/gortmp.Dial(0xc820d54150, 0x2e, 0x7ff70fa2f628, 0xc82106a240, 0x64, 0x0, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:96 +0x53f
main.DetectRtmp(0x770fe0, 0xc, 0xc8202e8f00)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:59 +0x1eb
main.Check.func1(0xc820aa4ed0, 0xc820aa4ee0, 0xc820d55e30, 0x771c20, 0xb, 0x770fe0, 0xc)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:119 +0xe3
created by main.Check
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:124 +0x1b4

goroutine 2863 [IO wait]:
net.runtime_pollWait(0x7ff711e58c10, 0x72, 0xc8200660a0)
/usr/lib/golang/src/runtime/netpoll.go:157 +0x60
net.(_pollDesc).Wait(0xc821247c60, 0x72, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x3a
net.(_pollDesc).WaitRead(0xc821247c60, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x36
net.(_netFD).Read(0xc821247c00, 0xc820107000, 0x1000, 0x1000, 0x0, 0x7ff70fa2a028, 0xc8200660a0)
/usr/lib/golang/src/net/fd_unix.go:232 +0x23a
net.(_conn).Read(0xc820b271f8, 0xc820107000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/net.go:172 +0xe4
net/http.(_liveSwitchReader).Read(0xc8204a80f8, 0xc820107000, 0x1000, 0x1000, 0xc820b28010, 0x0, 0x0)
/usr/lib/golang/src/net/http/server.go:219 +0xa4
io.(_LimitedReader).Read(0xc8200d1560, 0xc820107000, 0x1000, 0x1000, 0xffffffffffffffff, 0x0, 0x0)
/usr/lib/golang/src/io/io.go:427 +0xbd
bufio.(_Reader).fill(0xc82001d800)
/usr/lib/golang/src/bufio/bufio.go:97 +0x1e9
bufio.(_Reader).ReadSlice(0xc82001d800, 0xc81fff7b0a, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/bufio/bufio.go:328 +0x21a
bufio.(_Reader).ReadLine(0xc82001d800, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/bufio/bufio.go:357 +0x53
net/textproto.(_Reader).readLineSlice(0xc820a74540, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/textproto/reader.go:55 +0x81
net/textproto.(_Reader).ReadLine(0xc820a74540, 0x0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/textproto/reader.go:36 +0x40
net/http.ReadRequest(0xc82001d800, 0xc8201081c0, 0x0, 0x0)
/usr/lib/golang/src/net/http/request.go:653 +0xb6
net/http.(_conn).readRequest(0xc8204a80b0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/http/server.go:633 +0x32f
net/http.(_conn).serve(0xc8204a80b0)
/usr/lib/golang/src/net/http/server.go:1319 +0x727
created by net/http.(_Server).Serve
/usr/lib/golang/src/net/http/server.go:1910 +0x3f6

goroutine 2001 [IO wait, 8 minutes]:
net.runtime_pollWait(0x7ff70fa2f088, 0x72, 0xc8200660a0)
/usr/lib/golang/src/runtime/netpoll.go:157 +0x60
net.(_pollDesc).Wait(0xc821246060, 0x72, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x3a
net.(_pollDesc).WaitRead(0xc821246060, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x36
net.(_netFD).Read(0xc821246000, 0xc8202d4000, 0x1000, 0x1000, 0x0, 0x7ff70fa2a028, 0xc8200660a0)
/usr/lib/golang/src/net/fd_unix.go:232 +0x23a
net.(_conn).Read(0xc820076028, 0xc8202d4000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/net.go:172 +0xe4
bufio.(_Reader).fill(0xc8202f0000)
/usr/lib/golang/src/bufio/bufio.go:97 +0x1e9
bufio.(_Reader).ReadByte(0xc8202f0000, 0x0, 0x0, 0x0)
/usr/lib/golang/src/bufio/bufio.go:229 +0x7a
github.com/zhangpeihao/gortmp.Handshake(0x7ff70fa2f670, 0xc820076028, 0xc8202f0000, 0xc82024e000, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/handshake.go:207 +0x622
github.com/zhangpeihao/gortmp.Dial(0xc821028030, 0x2e, 0x7ff70fa2f628, 0xc8207000e0, 0x64, 0x0, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:96 +0x53f
main.DetectRtmp(0x770fd0, 0xc, 0xc8209d3f00)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:59 +0x1eb
main.Check.func1(0xc820aa4ed0, 0xc820aa4ee0, 0xc820d55e30, 0x771c30, 0xb, 0x770fd0, 0xc)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:119 +0xe3
created by main.Check
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:124 +0x1b4

goroutine 2046 [IO wait, 8 minutes]:
net.runtime_pollWait(0x7ff70fa33458, 0x72, 0xc8200660a0)
/usr/lib/golang/src/runtime/netpoll.go:157 +0x60
net.(_pollDesc).Wait(0xc821246140, 0x72, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x3a
net.(_pollDesc).WaitRead(0xc821246140, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x36
net.(_netFD).Read(0xc8212460e0, 0xc820861000, 0x1000, 0x1000, 0x0, 0x7ff70fa2a028, 0xc8200660a0)
/usr/lib/golang/src/net/fd_unix.go:232 +0x23a
net.(_conn).Read(0xc820076048, 0xc820861000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/net.go:172 +0xe4
bufio.(_Reader).fill(0xc8202f05a0)
/usr/lib/golang/src/bufio/bufio.go:97 +0x1e9
bufio.(_Reader).ReadByte(0xc8202f05a0, 0x0, 0x0, 0x0)
/usr/lib/golang/src/bufio/bufio.go:229 +0x7a
github.com/zhangpeihao/gortmp.Handshake(0x7ff70fa2f670, 0xc820076048, 0xc8202f05a0, 0xc82024e100, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/handshake.go:207 +0x622
github.com/zhangpeihao/gortmp.Dial(0xc8210281e0, 0x2e, 0x7ff70fa2f628, 0xc820700560, 0x64, 0x0, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:96 +0x53f
main.DetectRtmp(0x771020, 0xc, 0xc8202ee700)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:59 +0x1eb
main.Check.func1(0xc820aa4ed0, 0xc820aa4ee0, 0xc820d55e30, 0x771be0, 0xb, 0x771020, 0xc)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:119 +0xe3
created by main.Check
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:124 +0x1b4

goroutine 2006 [IO wait, 8 minutes]:
net.runtime_pollWait(0x7ff711e3faa8, 0x72, 0xc8200660a0)
/usr/lib/golang/src/runtime/netpoll.go:157 +0x60
net.(_pollDesc).Wait(0xc8212461b0, 0x72, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x3a
net.(_pollDesc).WaitRead(0xc8212461b0, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x36
net.(_netFD).Read(0xc821246150, 0xc8203db000, 0x1000, 0x1000, 0x0, 0x7ff70fa2a028, 0xc8200660a0)
/usr/lib/golang/src/net/fd_unix.go:232 +0x23a
net.(_conn).Read(0xc820076040, 0xc8203db000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/net.go:172 +0xe4
bufio.(_Reader).fill(0xc8202f0480)
/usr/lib/golang/src/bufio/bufio.go:97 +0x1e9
bufio.(_Reader).ReadByte(0xc8202f0480, 0x0, 0x0, 0x0)
/usr/lib/golang/src/bufio/bufio.go:229 +0x7a
github.com/zhangpeihao/gortmp.Handshake(0x7ff70fa2f670, 0xc820076040, 0xc8202f0480, 0xc82024e0c0, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/handshake.go:207 +0x622
github.com/zhangpeihao/gortmp.Dial(0xc821028270, 0x2e, 0x7ff70fa2f628, 0xc8207006e0, 0x64, 0x0, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:96 +0x53f
main.DetectRtmp(0x771000, 0xc, 0xc8209ce700)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:59 +0x1eb
main.Check.func1(0xc820aa4ed0, 0xc820aa4ee0, 0xc820d55e30, 0x771c00, 0xb, 0x771000, 0xc)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:119 +0xe3
created by main.Check
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:124 +0x1b4

goroutine 2063 [IO wait, 8 minutes]:
net.runtime_pollWait(0x7ff711e3f4a8, 0x72, 0xc8200660a0)
/usr/lib/golang/src/runtime/netpoll.go:157 +0x60
net.(_pollDesc).Wait(0xc821247cd0, 0x72, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x3a
net.(_pollDesc).WaitRead(0xc821247cd0, 0x0, 0x0)
/usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x36
net.(_netFD).Read(0xc821247c70, 0xc82001b000, 0x1000, 0x1000, 0x0, 0x7ff70fa2a028, 0xc8200660a0)
/usr/lib/golang/src/net/fd_unix.go:232 +0x23a
net.(_conn).Read(0xc820076038, 0xc82001b000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/golang/src/net/net.go:172 +0xe4
bufio.(_Reader).fill(0xc8202f0240)
/usr/lib/golang/src/bufio/bufio.go:97 +0x1e9
bufio.(_Reader).ReadByte(0xc8202f0240, 0x0, 0x0, 0x0)
/usr/lib/golang/src/bufio/bufio.go:229 +0x7a
github.com/zhangpeihao/gortmp.Handshake(0x7ff70fa2f670, 0xc820076038, 0xc8202f0240, 0xc82024e080, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/handshake.go:207 +0x622
github.com/zhangpeihao/gortmp.Dial(0xc821028150, 0x2e, 0x7ff70fa2f628, 0xc8207003e0, 0x64, 0x0, 0x0, 0x0, 0x0)
/root/yang/gopath/src/github.com/zhangpeihao/gortmp/outboundconn.go:96 +0x53f
main.DetectRtmp(0x771010, 0xc, 0xc82048ef00)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:59 +0x1eb
main.Check.func1(0xc820aa4ed0, 0xc820aa4ee0, 0xc820d55e30, 0x771bf0, 0xb, 0x771010, 0xc)
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:119 +0xe3
created by main.Check
/root/yang/upsrs/upsrs_api/check/server/check_srs_edge_server.go:124 +0x1b4

rax 0xca
rbx 0x0
rcx 0xffffffffffffffff
rdx 0x0
rdi 0x90d4f0
rsi 0x0
rbp 0x1
rsp 0x7fff8e9fbac8
r8 0x0
r9 0x0
r10 0x0
r11 0x286
r12 0xa
r13 0x7f9dae
r14 0xf
r15 0x8
rip 0x45f5b1
rflags 0x286
cs 0x33
fs 0x0
gs 0x0

@zhangpeihao
Copy link
Owner

Can you try to fix it? I will happy to merge your codes into master branch.

@hy05190134
Copy link
Contributor Author

@zhangpeihao thanks for merging my code into master, Now I just want to use your client code to generate a rtmp check server, it is useful for me. I will keep deep looking for the code and fix some bugs for you. If I have some questions, I will communicate with you .

@hy05190134
Copy link
Contributor Author

@zhangpeihao https://github.com/zhangpeihao/gortmp/blob/master/handshake.go#L207

因为我发现造成死锁的原因在于 handshake 读 s0 的时候一直在等待,这可能包括两个原因,一个是你这里的超时时间为0, 是否意味着一直需要等到读到 s0, 是否可以考虑设置一个超时时间;两一个原因是不是有可能 client 发送了 c0 + c1, 但是服务端没有收到,于是按照协议在没有收到 c1 前,服务端不会发送 s0

@zhangpeihao
Copy link
Owner

是的,这块是有问题。初始化时设置超时时间不对。我记得好像改过。

@hy05190134
Copy link
Contributor Author

@zhangpeihao 会不会存在发送 c0 + c1 后对方没有收到,超时时间为0,就一直等待的情况?

@zhangpeihao
Copy link
Owner

我周六看下

@hy05190134
Copy link
Contributor Author

@zhangpeihao 谢谢,你应该是流媒体专家吧,我是初学者,请多指教

@zhangpeihao
Copy link
Owner

HandShake之后,我把deadline关掉了。
你试试看吧

@hy05190134
Copy link
Contributor Author

@zhangpeihao 好的,你的意思是即使设置了 timeout, 也需要加这段话,那你之前的代码里 timeout 设置的是0 那肯定是不行了。

@zhangpeihao
Copy link
Owner

HandShake的timeout参数只是握手的超时,之后如果不去掉,会导致后面处理超时

@hy05190134
Copy link
Contributor Author

@zhangpeihao 比如我用 go routine 来检测某个 ip 的rtmp 是否有数据,如果有数据我就 close 了,但是我发现因为 内部有 read loop 和 write loop 导致 NewConn 分配的内存一直都释放不了,我的内存一直在涨,这个是存在这个问题吧。

@zhangpeihao
Copy link
Owner

timeout设置为0,握手就不会设置deadline,应该没有问题。

@hy05190134
Copy link
Contributor Author

hy05190134 commented May 5, 2016

@zhangpeihao 那我前面设置 timeout > 0 , 后面加上你之前加的 set deadline 语句,和你之前 timeout 设置为0 的效果一样吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants