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

Commite145cde

Browse files
mafredripull[bot]
authored andcommitted
fix: Prevent race between provisionerd connect and close (#6206)
* fix: Prevent race between provisionerd connect and close* test: Add detection for provisioner creation after test completion
1 parent91093d5 commite145cde

File tree

2 files changed

+126
-31
lines changed

2 files changed

+126
-31
lines changed

‎provisionerd/provisionerd.go‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,17 @@ func (p *Server) connect(ctx context.Context) {
177177
p.opts.Logger.Warn(context.Background(),"failed to dial",slog.Error(err))
178178
continue
179179
}
180+
// Ensure connection is not left hanging during a race between
181+
// close and dial succeeding.
182+
p.mutex.Lock()
183+
ifp.isClosed() {
184+
client.DRPCConn().Close()
185+
p.mutex.Unlock()
186+
break
187+
}
180188
p.clientValue.Store(client)
189+
p.mutex.Unlock()
190+
181191
p.opts.Logger.Debug(context.Background(),"connected")
182192
break
183193
}
@@ -390,7 +400,8 @@ func retryable(err error) bool {
390400
// is not retryable() or the context expires.
391401
func (p*Server)clientDoWithRetries(
392402
ctx context.Context,ffunc(context.Context, proto.DRPCProvisionerDaemonClient) (any,error)) (
393-
any,error) {
403+
any,error,
404+
) {
394405
forretrier:=retry.New(25*time.Millisecond,5*time.Second);retrier.Wait(ctx); {
395406
client,ok:=p.client()
396407
if!ok {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp