loop: remove unused waitForEnd parameter and endWaitGroup functionality
Remove wait_for_end query parameter and associated synchronization logic
that was not being used in the codebase.
Changes:
- Remove waitForEnd query parameter parsing in SSE handler
- Remove endWaitGroup sync.WaitGroup field from Server struct
- Simplify shutdown logic to use basic 100ms delay instead of complex waitgroup timeout
- Remove related comment documentation
This cleanup eliminates unused functionality while maintaining the same
shutdown behavior with simpler code.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s76684f9f4ec3a5d1k
diff --git a/loop/server/loophttp.go b/loop/server/loophttp.go
index 3b93d3e..b5fddb4 100644
--- a/loop/server/loophttp.go
+++ b/loop/server/loophttp.go
@@ -127,8 +127,6 @@
terminalSessions map[string]*terminalSession
sshAvailable bool
sshError string
- // WaitGroup for clients waiting for end
- endWaitGroup sync.WaitGroup
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@@ -767,29 +765,9 @@
// Log that we're shutting down
slog.Info("Ending session", "reason", endReason)
- // Wait for skaband clients that are waiting for end (with timeout)
+ // Give a brief moment for the response to be sent before exiting
go func() {
- startTime := time.Now()
- // Wait up to 2 seconds for waiting clients to receive the end message
- done := make(chan struct{})
- go func() {
- s.endWaitGroup.Wait()
- close(done)
- }()
-
- select {
- case <-done:
- slog.Info("All waiting clients notified of end")
- case <-time.After(2 * time.Second):
- slog.Info("Timeout waiting for clients, proceeding with shutdown")
- }
-
- // Ensure we've been running for at least 100ms to allow response to be sent
- elapsed := time.Since(startTime)
- if elapsed < 100*time.Millisecond {
- time.Sleep(100*time.Millisecond - elapsed)
- }
-
+ time.Sleep(100 * time.Millisecond)
os.Exit(0)
}()
})
@@ -1109,17 +1087,6 @@
}
}
- // Check if this client is waiting for end
- waitForEnd := r.URL.Query().Get("wait_for_end") == "true"
- if waitForEnd {
- s.endWaitGroup.Add(1)
- defer func() {
- if waitForEnd {
- s.endWaitGroup.Done()
- }
- }()
- }
-
// Ensure 'from' is valid
currentCount := s.agent.MessageCount()
if fromIndex < 0 {