From 24d1fe7c53e6abef49c8852928e5223ce16d8856 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Mar 2024 06:28:56 +0000 Subject: [PATCH] build(deps): bump github.com/thejerf/suture/v4 from 4.0.2 to 4.0.5 Bumps [github.com/thejerf/suture/v4](https://github.com/thejerf/suture) from 4.0.2 to 4.0.5. - [Commits](https://github.com/thejerf/suture/compare/v4.0.2...v4.0.5) --- updated-dependencies: - dependency-name: github.com/thejerf/suture/v4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/thejerf/suture/v4/LICENSE | 2 +- .../github.com/thejerf/suture/v4/messages.go | 10 ++- .../thejerf/suture/v4/supervisor.go | 61 +++++++++---------- vendor/modules.txt | 2 +- 6 files changed, 41 insertions(+), 40 deletions(-) diff --git a/go.mod b/go.mod index 505c2eb61..2a9155060 100644 --- a/go.mod +++ b/go.mod @@ -83,7 +83,7 @@ require ( github.com/spf13/afero v1.11.0 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 - github.com/thejerf/suture/v4 v4.0.2 + github.com/thejerf/suture/v4 v4.0.5 github.com/tidwall/gjson v1.17.1 github.com/tus/tusd v1.13.0 github.com/urfave/cli/v2 v2.27.1 diff --git a/go.sum b/go.sum index 7fa0bc241..3d4e7663d 100644 --- a/go.sum +++ b/go.sum @@ -2005,8 +2005,8 @@ github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= github.com/thanhpk/randstr v1.0.6 h1:psAOktJFD4vV9NEVb3qkhRSMvYh4ORRaj1+w/hn4B+o= github.com/thanhpk/randstr v1.0.6/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U= -github.com/thejerf/suture/v4 v4.0.2 h1:VxIH/J8uYvqJY1+9fxi5GBfGRkRZ/jlSOP6x9HijFQc= -github.com/thejerf/suture/v4 v4.0.2/go.mod h1:g0e8vwskm9tI0jRjxrnA6lSr0q6OfPdWJVX7G5bVWRs= +github.com/thejerf/suture/v4 v4.0.5 h1:F1E/4FZwXWqvlWDKEUo6/ndLtxGAUzMmNqkrMknZbAA= +github.com/thejerf/suture/v4 v4.0.5/go.mod h1:gu9Y4dXNUWFrByqRt30Rm9/UZ0wzRSt9AJS6xu/ZGxU= github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= diff --git a/vendor/github.com/thejerf/suture/v4/LICENSE b/vendor/github.com/thejerf/suture/v4/LICENSE index a1c666ea8..99c7cc597 100644 --- a/vendor/github.com/thejerf/suture/v4/LICENSE +++ b/vendor/github.com/thejerf/suture/v4/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2020 Barracuda Networks, Inc. +Copyright (c) 2014-2024 Barracuda Networks, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/github.com/thejerf/suture/v4/messages.go b/vendor/github.com/thejerf/suture/v4/messages.go index 380fd6ec2..8bd215357 100644 --- a/vendor/github.com/thejerf/suture/v4/messages.go +++ b/vendor/github.com/thejerf/suture/v4/messages.go @@ -21,7 +21,10 @@ type removeService struct { func (rs removeService) isSupervisorMessage() {} func (s *Supervisor) sync() { - s.control <- syncSupervisor{} + select { + case s.control <- syncSupervisor{}: + case <-s.liveness: + } } type syncSupervisor struct { @@ -30,7 +33,10 @@ type syncSupervisor struct { func (ss syncSupervisor) isSupervisorMessage() {} func (s *Supervisor) fail(id serviceID, panicVal interface{}, stacktrace []byte) { - s.control <- serviceFailed{id, panicVal, stacktrace} + select { + case s.control <- serviceFailed{id, panicVal, stacktrace}: + case <-s.liveness: + } } type serviceFailed struct { diff --git a/vendor/github.com/thejerf/suture/v4/supervisor.go b/vendor/github.com/thejerf/suture/v4/supervisor.go index e7e9ed61d..0ab5f99d2 100644 --- a/vendor/github.com/thejerf/suture/v4/supervisor.go +++ b/vendor/github.com/thejerf/suture/v4/supervisor.go @@ -14,6 +14,7 @@ import ( "math/rand" "runtime" "sync" + "sync/atomic" "time" ) @@ -50,11 +51,10 @@ program will be to call one of the Serve methods. Calling ServeBackground will CORRECTLY start the supervisor running in a new goroutine. It is risky to directly run - go supervisor.Serve() + go supervisor.Serve() because that will briefly create a race condition as it starts up, if you try to .Add() services immediately afterward. - */ type Supervisor struct { Name string @@ -97,7 +97,6 @@ type Supervisor struct { } /* - New is the full constructor function for a supervisor. The name is a friendly human name for the supervisor, used in logging. Suture @@ -105,21 +104,26 @@ does not care if this is unique, but it is good for your sanity if it is. If not set, the following values are used: - * EventHook: A function is created that uses log.Print. - * FailureDecay: 30 seconds - * FailureThreshold: 5 failures - * FailureBackoff: 15 seconds - * Timeout: 10 seconds - * BackoffJitter: DefaultJitter + - EventHook: A function is created that uses log.Print. + - FailureDecay: 30 seconds + - FailureThreshold: 5 failures + - FailureBackoff: 15 seconds + - Timeout: 10 seconds + - BackoffJitter: DefaultJitter The EventHook function will be called when errors occur. Suture will log the following: - * When a service has failed, with a descriptive message about the - current backoff status, and whether it was immediately restarted - * When the supervisor has gone into its backoff mode, and when it - exits it - * When a service fails to stop + - When a service has failed, with a descriptive message about the + current backoff status, and whether it was immediately restarted + - When the supervisor has gone into its backoff mode, and when it + exits it + - When a service fails to stop + +A slog-based EventHook is provided in the submodule sutureslog. Note +that it is a separate Go module, in order to avoid imposing a Go 1.21 +requirement on this module, so a separate go get step will be +necessary to use it. The failureRate, failureThreshold, and failureBackoff controls how failures are handled, in order to avoid the supervisor failure case where the @@ -145,7 +149,6 @@ DontPropagateTermination indicates whether this supervisor tree will propagate a ErrTerminateTree if a child process returns it. If false, this supervisor will itself return an error that will terminate its parent. If true, it will merely return ErrDoNotRestart. false by default. - */ func New(name string, spec Spec) *Supervisor { spec.configureDefaults(name) @@ -254,7 +257,6 @@ supervisor being added will copy the EventHook function from the Supervisor it is being added to. This allows factoring out providing a Supervisor from its logging. This unconditionally overwrites the child Supervisor's logging functions. - */ func (s *Supervisor) Add(service Service) ServiceToken { if s == nil { @@ -277,7 +279,7 @@ func (s *Supervisor) Add(service Service) ServiceToken { s.restartQueue = append(s.restartQueue, id) s.m.Unlock() - return ServiceToken{uint64(s.id)<<32 | uint64(id)} + return ServiceToken{supervisor: s.id, service: id} } s.m.Unlock() @@ -285,7 +287,7 @@ func (s *Supervisor) Add(service Service) ServiceToken { if s.sendControl(addService{service, serviceName(service), response}) != nil { return ServiceToken{} } - return ServiceToken{uint64(s.id)<<32 | uint64(<-response)} + return ServiceToken{supervisor: s.id, service: <-response} } // ServeBackground starts running a supervisor in its own goroutine. When @@ -652,7 +654,7 @@ SHUTTING_DOWN_SERVICES: SupervisorPath: []*Supervisor{s}, Service: serviceWithName.Service, Name: serviceWithName.name, - ServiceToken: ServiceToken{uint64(s.id)<<32 | uint64(serviceID)}, + ServiceToken: ServiceToken{supervisor: s.id, service: serviceID}, }) } s.m.Lock() @@ -694,11 +696,10 @@ The ServiceID token comes from the Add() call. This returns without waiting for the service to stop. */ func (s *Supervisor) Remove(id ServiceToken) error { - sID := supervisorID(id.id >> 32) - if sID != s.id { + if id.supervisor != s.id { return ErrWrongSupervisor } - err := s.sendControl(removeService{serviceID(id.id & 0xffffffff), nil}) + err := s.sendControl(removeService{id.service, nil}) if err == ErrSupervisorNotRunning { // No meaningful error handling if the supervisor is stopped. return nil @@ -717,8 +718,7 @@ passes, ErrTimeout is returned. (If this isn't even the right supervisor ErrWrongSupervisor is returned.) */ func (s *Supervisor) RemoveAndWait(id ServiceToken, timeout time.Duration) error { - sID := supervisorID(id.id >> 32) - if sID != s.id { + if id.supervisor != s.id { return ErrWrongSupervisor } @@ -732,7 +732,7 @@ func (s *Supervisor) RemoveAndWait(id ServiceToken, timeout time.Duration) error notificationC := make(chan struct{}) - sentControlErr := s.sendControl(removeService{serviceID(id.id & 0xffffffff), notificationC}) + sentControlErr := s.sendControl(removeService{id.service, notificationC}) if sentControlErr != nil { return sentControlErr @@ -756,10 +756,8 @@ func (s *Supervisor) RemoveAndWait(id ServiceToken, timeout time.Duration) error } /* - Services returns a []Service containing a snapshot of the services this Supervisor is managing. - */ func (s *Supervisor) Services() []Service { ls := listServices{make(chan []Service)} @@ -770,20 +768,17 @@ func (s *Supervisor) Services() []Service { return nil } -var currentSupervisorIDL sync.Mutex var currentSupervisorID uint32 func nextSupervisorID() supervisorID { - currentSupervisorIDL.Lock() - defer currentSupervisorIDL.Unlock() - currentSupervisorID++ - return supervisorID(currentSupervisorID) + return supervisorID(atomic.AddUint32(¤tSupervisorID, 1)) } // ServiceToken is an opaque identifier that can be used to terminate a service that // has been Add()ed to a Supervisor. type ServiceToken struct { - id uint64 + supervisor supervisorID + service serviceID } // An UnstoppedService is the component member of an diff --git a/vendor/modules.txt b/vendor/modules.txt index 6634b469c..035031780 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1756,7 +1756,7 @@ github.com/studio-b12/gowebdav # github.com/tchap/go-patricia/v2 v2.3.1 ## explicit; go 1.16 github.com/tchap/go-patricia/v2/patricia -# github.com/thejerf/suture/v4 v4.0.2 +# github.com/thejerf/suture/v4 v4.0.5 ## explicit; go 1.9 github.com/thejerf/suture/v4 # github.com/tidwall/gjson v1.17.1