Skip to content

Commit

Permalink
Merge pull request #11 from yedamao/inactive-connection-close
Browse files Browse the repository at this point in the history
Receiver: Session add debug mode
  • Loading branch information
yedamao authored Sep 11, 2019
2 parents 390efb9 + a9a7d79 commit e3a5f9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sgip/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (r *Receiver) worker(id int) {

log.Println("worker ", id, ": Accept ", conn)

session := NewSession(conn, r.handler, r.done)
session := NewSession(conn, r.handler, r.done, r.debug)
// block
session.Run()
}
Expand Down
13 changes: 12 additions & 1 deletion sgip/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@ type Session struct {
isClose uint64
done chan struct{}
serverDone chan struct{}

// debug flag
debug bool
}

func NewSession(connection net.Conn, handler Handler, done chan struct{}) *Session {
func NewSession(
connection net.Conn, handler Handler,
done chan struct{}, debug bool,
) *Session {

return &Session{
handler: handler,
conn: *conn.NewConn(connection),
pipe: make(chan protocol.Operation),
done: make(chan struct{}),
serverDone: done,
debug: debug,
}
}

Expand Down Expand Up @@ -102,6 +109,10 @@ func (s *Session) recvWorker() {
return
}

if s.debug {
log.Println(op)
}

s.pipe <- op
}
}
Expand Down

0 comments on commit e3a5f9a

Please sign in to comment.