summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-02 13:50:24 +0200
committerPaul Buetow <paul@buetow.org>2026-03-02 13:50:24 +0200
commit81e79a1daf26475f020605dd92970c9bf5b112fe (patch)
tree3cd05f5fd1e9f5af80eda92e34a31d31eca72ba7
parent8285f000444be9a301e06be47cb5ff2c858dc732 (diff)
lsp: make exit flag atomic to avoid data race (task 406)
-rw-r--r--internal/lsp/handlers_init.go2
-rw-r--r--internal/lsp/server.go5
2 files changed, 4 insertions, 3 deletions
diff --git a/internal/lsp/handlers_init.go b/internal/lsp/handlers_init.go
index 29dc803..702871d 100644
--- a/internal/lsp/handlers_init.go
+++ b/internal/lsp/handlers_init.go
@@ -40,5 +40,5 @@ func (s *Server) handleShutdown(req Request) {
}
func (s *Server) handleExit() {
- s.exited = true
+ s.exited.Store(true)
}
diff --git a/internal/lsp/server.go b/internal/lsp/server.go
index dc76975..730169f 100644
--- a/internal/lsp/server.go
+++ b/internal/lsp/server.go
@@ -8,6 +8,7 @@ import (
"log"
"strings"
"sync"
+ "sync/atomic"
"time"
"codeberg.org/snonux/hexai/internal/appconfig"
@@ -24,7 +25,7 @@ type Server struct {
out io.Writer
outMu sync.Mutex
logger *log.Logger
- exited bool
+ exited atomic.Bool
mu sync.RWMutex
docs map[string]*document
logContext bool
@@ -415,7 +416,7 @@ func (s *Server) Run() error {
continue
}
go s.handle(req)
- if s.exited {
+ if s.exited.Load() {
return nil
}
}