Skip to content

Commit

Permalink
fix leak (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 authored Dec 27, 2021
1 parent 3c231ca commit efdfc7b
Show file tree
Hide file tree
Showing 154 changed files with 14 additions and 30,487 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
_obj
_test
.vscode
vendor

# Architecture specific extensions/prefixes
*.[568vq]
Expand All @@ -23,3 +24,4 @@ _testmain.go
*.exe
*.test
*.prof

27 changes: 12 additions & 15 deletions application.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,22 @@ func (s *server) Stop() error {
s.mu.Unlock()
return nil
}
s.mu.running = false
s.mu.Unlock()

s.listener.Close()
s.opts.logger.Info("application listener closed")
c := make(chan struct{})
go func() {
for _, m := range s.sessions {
m.Lock()
for k, rs := range m.sessions {
delete(m.sessions, k)
rs.Close()
}
m.Unlock()
}
close(c)
}()
<-c
s.mu.running = false
s.mu.Unlock()
<-s.closedC

// now no new connection will added, close all active sessions
for _, m := range s.sessions {
m.Lock()
for k, rs := range m.sessions {
delete(m.sessions, k)
rs.Close()
}
m.Unlock()
}
s.opts.logger.Info("application stopped")
return nil
}
Expand Down
15 changes: 0 additions & 15 deletions vendor/github.com/davecgh/go-spew/LICENSE

This file was deleted.

145 changes: 0 additions & 145 deletions vendor/github.com/davecgh/go-spew/spew/bypass.go

This file was deleted.

38 changes: 0 additions & 38 deletions vendor/github.com/davecgh/go-spew/spew/bypasssafe.go

This file was deleted.

Loading

0 comments on commit efdfc7b

Please sign in to comment.