Skip to content

Commit

Permalink
Merge pull request #36 from chinaerserver/master
Browse files Browse the repository at this point in the history
Mod: remove useless return and make runUDPEventLoop run in goroutine
  • Loading branch information
AlexStocks authored Apr 17, 2020
2 parents d927e3e + 0a0a806 commit fe594be
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions transport/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,23 @@ func (s *server) runTcpEventLoop(newSession NewSessionCallback) {
}

func (s *server) runUDPEventLoop(newSession NewSessionCallback) {
var (
ss Session
)
s.wg.Add(1)
go func() {
defer s.wg.Done()
var (
err error
conn *net.UDPConn
ss Session
)

ss = newUDPSession(s.pktListener.(*net.UDPConn), s)
if err := newSession(ss); err != nil {
panic(err.Error())
}
ss.(*session).run()
conn = s.pktListener.(*net.UDPConn)
ss = newUDPSession(conn, s)
if err = newSession(ss); err != nil {
conn.Close()
panic(err.Error())
}
ss.(*session).run()
}()
}

type wsHandler struct {
Expand Down Expand Up @@ -384,7 +392,6 @@ func (s *server) runWSSEventLoop(newSession NewSessionCallback) {
if certificate, err = tls.LoadX509KeyPair(s.cert, s.privateKey); err != nil {
panic(fmt.Sprintf("tls.LoadX509KeyPair(cert{%s}, privateKey{%s}) = err{%s}",
s.cert, s.privateKey, jerrors.ErrorStack(err)))
return
}
config = &tls.Config{
InsecureSkipVerify: true, // do not verify peer cert
Expand Down

0 comments on commit fe594be

Please sign in to comment.