pico

created pr with 100.1 on 2025-12-26T04:53:44Z · by c8ef7d19
cmds
checkout latest patchset:
ssh pr.pico.sh print 100 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 100.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 100

Patchset 100.1 on 2025-12-26T04:53:44Z · commit bda8890

fix(pipe): use ticker timer instead of sleep
Eric Bower 2025-12-26T04:45:05Z
The time.Sleep in the default case blocks for 5 seconds, during which context cancellation is ignored.
If the session ends, the goroutine won't notice until the sleep completes.
Semantic diff summary
0 added, 1 modified, 0 signature changed, 0 removed across 1 analyzed file
+19 -19 pkg/apps/pipe/cli.go #
......@@ -52,25 +52,6 @@ func Middleware(handler *CliHandler) pssh.SSHServerMiddleware {
5252
5353 pipeCtx, cancel := context.WithCancel(ctx)
5454
55- go func() {
56- defer cancel()
57-
58- for {
59- select {
60- case <-pipeCtx.Done():
61- return
62- default:
63- _, err := sesh.SendRequest("ping@pico.sh", false, nil)
64- if err != nil {
65- logger.Error("error sending ping", "err", err)
66- return
67- }
68-
69- time.Sleep(5 * time.Second)
70- }
71- }
72- }()
73-
7455 cliCmd := &CliCmd{
7556 sesh: sesh,
7657 args: args,
......@@ -118,6 +99,25 @@ func Middleware(handler *CliHandler) pssh.SSHServerMiddleware {
11899 sesh.RemoteAddr().String(),
119100 )
120101
102+ defer cancel()
103+ go func() {
104+ ticker := time.NewTicker(5 * time.Second)
105+ defer ticker.Stop()
106+
107+ for {
108+ select {
109+ case <-pipeCtx.Done():
110+ return
111+ case <-ticker.C:
112+ _, err := sesh.SendRequest("ping@pico.sh", false, nil)
113+ if err != nil {
114+ logger.Error("error sending ping", "err", err)
115+ return
116+ }
117+ }
118+ }
119+ }()
120+
121121 switch cmd {
122122 case "pub":
123123 err := handler.pub(cliCmd, topic, clientID)
Back to top