Skip to content

Commit

Permalink
add a log func for mux session err
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana committed Dec 10, 2021
1 parent 89ae2bc commit d42c818
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package core

import (
"github.com/xtaci/smux"
"log"
"net"
"net/http"
Expand All @@ -33,3 +34,7 @@ func logConnErr(conn net.Conn, err error) {
func logRequestErr(r *http.Request, err error) {
errLogger.Printf("request from %s %s: %v", r.RemoteAddr, r.RequestURI, err)
}

func logMuxSessErr(s *smux.Session, err error) {
errLogger.Printf("mux session %s <-> %s: %v", s.RemoteAddr(), s.LocalAddr(), err)
}
3 changes: 1 addition & 2 deletions core/smux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"github.com/xtaci/smux"
"io"
"log"
"net"
"sync"
"time"
Expand Down Expand Up @@ -115,7 +114,7 @@ func (m *MuxTransport) tryGetStream() (stream *smux.Stream) {

s, err := sess.OpenStream()
if err != nil {
log.Printf("sess err: %v", err)
logMuxSessErr(sess, err)
sess.Close()
m.sm.Lock()
delete(m.sess, sess)
Expand Down

0 comments on commit d42c818

Please sign in to comment.