service/dap: tune up shutdown logic (#2564)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
This commit is contained in:
parent
1b0c4310c4
commit
9dfd164cf9
@ -269,13 +269,6 @@ func (s *Server) Stop() {
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.conn != nil {
|
||||
// Unless Stop() was called after serveDAPCodec()
|
||||
// returned, this will result in closed connection error
|
||||
// on next read, breaking out of the read loop and
|
||||
// allowing the run goroutine to exit.
|
||||
_ = s.conn.Close()
|
||||
}
|
||||
|
||||
if s.debugger != nil {
|
||||
killProcess := s.config.Debugger.AttachPid == 0
|
||||
@ -286,7 +279,15 @@ func (s *Server) Stop() {
|
||||
// The binary is no longer in use by the debugger. It is safe to remove it.
|
||||
if s.binaryToRemove != "" {
|
||||
gobuild.Remove(s.binaryToRemove)
|
||||
s.binaryToRemove = ""
|
||||
}
|
||||
// Close client connection last, so other shutdown stages
|
||||
// can send client notifications
|
||||
if s.conn != nil {
|
||||
// Unless Stop() was called after serveDAPCodec()
|
||||
// returned, this will result in closed connection error
|
||||
// on next read, breaking out of the read loop and
|
||||
// allowing the run goroutine to exit.
|
||||
_ = s.conn.Close()
|
||||
}
|
||||
s.log.Debug("DAP server stopped")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user