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

Commit84dd68a

Browse files
committed
Try#2 - don't create chan every acquirejob
1 parent42ce721 commit84dd68a

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

‎provisionerd/provisionerd.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ func New(clientDialer Dialer, opts *Options) io.Closer {
5050
}
5151
ctx,ctxCancel:=context.WithCancel(context.Background())
5252
daemon:=&provisionerDaemon{
53-
clientDialer:clientDialer,
54-
opts:opts,
55-
56-
closeContext:ctx,
57-
closeCancel:ctxCancel,
58-
closed:make(chanstruct{}),
53+
clientDialer:clientDialer,
54+
opts:opts,
55+
acquiredJobDone:make(chanstruct{}),
56+
closeContext:ctx,
57+
closeCancel:ctxCancel,
58+
closed:make(chanstruct{}),
5959
}
6060
godaemon.connect(ctx)
6161
returndaemon
@@ -185,8 +185,6 @@ func (p *provisionerDaemon) acquireJob(ctx context.Context) {
185185
p.acquiredJobCancelled.Store(false)
186186
p.acquiredJobRunning.Store(true)
187187

188-
p.acquiredJobDone=make(chanstruct{})
189-
190188
p.opts.Logger.Info(context.Background(),"acquired job",
191189
slog.F("job_id",p.acquiredJob.JobId),
192190
slog.F("organization_name",p.acquiredJob.OrganizationName),
@@ -515,15 +513,6 @@ func (p *provisionerDaemon) closeWithError(err error) error {
515513
}
516514

517515
ifp.isRunningJob() {
518-
// We also need the 'acquire job' mutex here,
519-
// so that a new `p.acquiredJobDone` channel isn't created
520-
// while we're waiting on the mutex.
521-
522-
// Note the mutex order - it's important that we always use the same order of acquisition
523-
// to avoid deadlocks
524-
p.acquiredJobMutex.Lock()
525-
deferp.acquiredJobMutex.Unlock()
526-
527516
errMsg:="provisioner daemon was shutdown gracefully"
528517
iferr!=nil {
529518
errMsg=err.Error()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp