Skip to content

Commit c7d1a60

Browse files
gloursclaude
authored andcommitted
fix: use pointer receivers for composeService methods with sync.Once fields
Moving runtimeVersionCache from a package-level var to instance fields on composeService caused copylocks violations in methods using value receivers, since sync.Once contains sync.noCopy. Switch the 4 affected methods to pointer receivers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
1 parent 5f6f35e commit c7d1a60

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

pkg/compose/build_bake.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ func dockerFilePath(ctxName string, dockerfile string) string {
568568
return dockerfile
569569
}
570570

571-
func (s composeService) dryRunBake(cfg bakeConfig) map[string]string {
571+
func (s *composeService) dryRunBake(cfg bakeConfig) map[string]string {
572572
bakeResponse := map[string]string{}
573573
for name, target := range cfg.Targets {
574574
dryRunUUID := fmt.Sprintf("dryRun-%x", sha1.Sum([]byte(name)))
@@ -581,7 +581,7 @@ func (s composeService) dryRunBake(cfg bakeConfig) map[string]string {
581581
return bakeResponse
582582
}
583583

584-
func (s composeService) displayDryRunBuildEvent(name, dryRunUUID, tag string) {
584+
func (s *composeService) displayDryRunBuildEvent(name, dryRunUUID, tag string) {
585585
s.events.On(api.Resource{
586586
ID: name + " ==>",
587587
Status: api.Done,

pkg/compose/hook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/docker/compose/v5/pkg/utils"
3232
)
3333

34-
func (s composeService) runHook(ctx context.Context, ctr container.Summary, service types.ServiceConfig, hook types.ServiceHook, listener api.ContainerEventListener) error {
34+
func (s *composeService) runHook(ctx context.Context, ctr container.Summary, service types.ServiceConfig, hook types.ServiceHook, listener api.ContainerEventListener) error {
3535
wOut := utils.GetWriter(func(line string) {
3636
listener(api.ContainerEvent{
3737
Type: api.HookEventLog,
@@ -96,7 +96,7 @@ func (s composeService) runHook(ctx context.Context, ctr container.Summary, serv
9696
return nil
9797
}
9898

99-
func (s composeService) runWaitExec(ctx context.Context, execID string, service types.ServiceConfig, listener api.ContainerEventListener) error {
99+
func (s *composeService) runWaitExec(ctx context.Context, execID string, service types.ServiceConfig, listener api.ContainerEventListener) error {
100100
_, err := s.apiClient().ExecStart(ctx, execID, client.ExecStartOptions{
101101
Detach: listener == nil,
102102
TTY: service.Tty,

0 commit comments

Comments
 (0)