Files
sshtermy/internal/gui/queue.go
T
db9979andClaude Opus 5.5 d315d06e77 Stabilität: Absturzschutz, Zeitgrenzen, Selbstprüfung, mehr Tests, Dauerlauf (#175)
* Absturzschutz: Fehler in Hintergrundarbeit beenden sshTermy nicht mehr; Zeitgrenzen für Update-Download und Team-Abo; Gast-Tasten über Warteschlange

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* CI: Zeitgrenzen je Job, alte Läufe abbrechen, Tests in zufälliger Reihenfolge; make check; Bibliotheken aktualisiert

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* update: Stillstand auch ohne Lesefehler erkennen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Zufallstests für Teilen, Vermittler, MCP, Syslog, KI-Antworten, Sync und Fenster-Rahmen; Syslog-Empfang übersteht kaputte Pakete; MCP antwortet auch nach Fehler

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Tests: Tresor (Passwortwechsel, Sperre, Blobs, KDF-Grenzen), SFTP-Rundreise, serielle Konsole mit Ersatzkabel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Dauerlauf-Test (make soak) und nächtlicher Lauf mit langen Zufallstests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Fuzz: Zeitlimit je Eingabe auch für die neuen Tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Selbstprüfung: sshtermy doctor und Palette › Hilfe › Fehlersuche; versehentlich eingecheckte Programmdatei entfernt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Oberfläche aufteilen, erster Schritt: Mausbereiche (ui/clickzone) und abgelegte Dateien (ui/dropped) als eigene Pakete

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Doku: Absturzschutz und Selbstprüfung in README, Webseite und Handbuch; Plan zur Aufteilung von internal/ui; Zusehen-WASM neu gebaut

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-20 12:23:50 +01:00

63 lines
1.3 KiB
Go

package gui
import (
"io"
"sync"
"github.com/db9979/sshtermy/internal/safe"
)
// queueWriter reicht Bytes in eigener Goroutine weiter, in Reihenfolge, und
// blockiert den Aufrufer nie.
//
// Warum: Mausereignisse laufen durch den Emulator (SendMouse), der dabei
// seine Sperre hält, bis die Bytes abgenommen sind. Hängt die Gegenseite
// gerade, weil bubbletea ein Bild in denselben Emulator schreibt (braucht
// dieselbe Sperre), stünde alles still: Schnelles Mausrad in langen Listen
// hat das Fenster so eingefroren. Tasten gehen denselben Weg, damit sie
// in Reihenfolge mit Maus und Einfügen bleiben.
type queueWriter struct {
mu sync.Mutex
cond *sync.Cond
buf []byte
err error
dst io.Writer
}
func newQueueWriter(dst io.Writer) *queueWriter {
q := &queueWriter{dst: dst}
q.cond = sync.NewCond(&q.mu)
safe.Go("gui/queue.go", func() { q.loop() })
return q
}
func (q *queueWriter) Write(p []byte) (int, error) {
q.mu.Lock()
defer q.mu.Unlock()
if q.err != nil {
return 0, q.err
}
q.buf = append(q.buf, p...)
q.cond.Signal()
return len(p), nil
}
func (q *queueWriter) loop() {
for {
q.mu.Lock()
for len(q.buf) == 0 {
q.cond.Wait()
}
b := q.buf
q.buf = nil
q.mu.Unlock()
if _, err := q.dst.Write(b); err != nil {
q.mu.Lock()
q.err = err
q.buf = nil
q.mu.Unlock()
return
}
}
}