Skip to content

Commit

Permalink
Remove func Close
Browse files Browse the repository at this point in the history
  • Loading branch information
watal authored and Motok1 committed Oct 19, 2022
1 parent ab697eb commit b106fe3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 4 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@ func (s *Server) Listen(address string, port string, lspChan chan Lsp) error {
go func() {
session.Established()
s.logger.Info("Remove PCEP session", zap.String("session", session.peerAddr.String()))
s.removeSession(session)
s.closeSession(session)
}()
sessionId += 1
}
}

func (s *Server) removeSession(session *Session) {
func (s *Server) closeSession(session *Session) {
session.tcpConn.Close()

// Remove Session List
for i, v := range s.sessionList {
if v.sessionId == session.sessionId {
Expand Down
5 changes: 0 additions & 5 deletions pkg/server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ type Session struct {
logger *zap.Logger
}

func (s *Session) Close() {
s.tcpConn.Close()
}

func NewSession(sessionId uint8, lspChan chan Lsp, logger *zap.Logger) *Session {
s := &Session{
sessionId: sessionId,
Expand All @@ -43,7 +39,6 @@ func NewSession(sessionId uint8, lspChan chan Lsp, logger *zap.Logger) *Session
}

func (s *Session) Established() {
defer s.Close()
if err := s.Open(); err != nil {
s.logger.Info("PCEP OPEN error", zap.String("session", s.peerAddr.String()), zap.Error(err))
return
Expand Down

0 comments on commit b106fe3

Please sign in to comment.