Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit34c5c1a

Browse files
committed
Avoid wait callback when context expires
1 parentd4170ca commit34c5c1a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

‎agent/reconnectingpty/buffered.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (rpty *bufferedReconnectingPTY) Attach(ctx context.Context, connID string,
191191
}
192192

193193
ifstate!=StateReady {
194-
returnxerrors.Errorf("reconnecting pty ready wait: %w",err)
194+
returnerr
195195
}
196196

197197
goheartbeat(ctx,rpty.timer,rpty.timeout)
@@ -210,7 +210,7 @@ func (rpty *bufferedReconnectingPTY) Attach(ctx context.Context, connID string,
210210
returnnil
211211
})
212212
iferr!=nil {
213-
returnerr
213+
returnxerrors.Errorf("reconnecting pty ready wait: %w",err)
214214
}
215215

216216
deferfunc() {

‎agent/reconnectingpty/reconnectingpty.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ func (s *ptyState) waitForState(state State) (State, error) {
168168

169169
// waitForStateOrContext blocks until the state or a greater one is reached or
170170
// the provided context ends. If fn is non-nil it will be ran while the lock is
171-
// held and fn's error will replace waitForStateOrContext's error.
171+
// held unless the context ends, and fn's error will replace
172+
// waitForStateOrContext's error.
172173
func (s*ptyState)waitForStateOrContext(ctx context.Context,stateState,fnfunc(stateState,errerror)error) (State,error) {
173174
nevermind:=make(chanstruct{})
174175
deferclose(nevermind)
@@ -186,14 +187,13 @@ func (s *ptyState) waitForStateOrContext(ctx context.Context, state State, fn fu
186187
forctx.Err()==nil&&state>s.state {
187188
s.cond.Wait()
188189
}
189-
err:=s.error
190190
ifctx.Err()!=nil {
191-
err=ctx.Err()
191+
returns.state,ctx.Err()
192192
}
193193
iffn!=nil {
194-
returns.state,fn(s.state,err)
194+
returns.state,fn(s.state,s.error)
195195
}
196-
returns.state,err
196+
returns.state,s.error
197197
}
198198

199199
// readConnLoop reads messages from conn and writes to ptty as needed. Blocks

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp