Merge branch 'dev' of https://github.com/cnlh/nps into dev

pull/291/head
unknown 2019-12-04 17:42:07 +08:00
commit bc23c53981
1 changed files with 10 additions and 0 deletions

View File

@ -1,8 +1,10 @@
package client package client
import ( import (
"errors"
"net" "net"
"net/http" "net/http"
"runtime"
"sync" "sync"
"time" "time"
@ -31,6 +33,14 @@ type p2pBridge struct {
} }
func (p2pBridge *p2pBridge) SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (target net.Conn, err error) { func (p2pBridge *p2pBridge) SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (target net.Conn, err error) {
for i := 0; muxSession == nil; i++ {
if i >= 20 {
err = errors.New("p2pBridge:too many times to get muxSession")
logs.Error(err)
return
}
runtime.Gosched() // waiting for another goroutine establish the mux connection
}
nowConn, err := muxSession.NewConn() nowConn, err := muxSession.NewConn()
if err != nil { if err != nil {
udpConn = nil udpConn = nil