浏览代码

all, vendor: Switch back to non-forked thejerf/suture (#5171)

Jakob Borg 7 年之前
父节点
当前提交
9e00b619ab

+ 2 - 2
cmd/stdiscosrv/main.go

@@ -19,11 +19,11 @@ import (
 	"strings"
 	"strings"
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/tlsutil"
 	"github.com/syncthing/syncthing/lib/tlsutil"
 	"github.com/syndtr/goleveldb/leveldb/opt"
 	"github.com/syndtr/goleveldb/leveldb/opt"
+	"github.com/thejerf/suture"
 )
 )
 
 
 const (
 const (
@@ -165,7 +165,7 @@ func main() {
 
 
 	// Root of the service tree.
 	// Root of the service tree.
 	main := suture.New("main", suture.Spec{
 	main := suture.New("main", suture.Spec{
-		PanicPanics: true,
+		PassThroughPanics: true,
 	})
 	})
 
 
 	// Start the database.
 	// Start the database.

+ 3 - 3
cmd/syncthing/gui_test.go

@@ -23,13 +23,13 @@ import (
 	"testing"
 	"testing"
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
 	"github.com/d4l3k/messagediff"
 	"github.com/d4l3k/messagediff"
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/events"
 	"github.com/syncthing/syncthing/lib/events"
 	"github.com/syncthing/syncthing/lib/fs"
 	"github.com/syncthing/syncthing/lib/fs"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/sync"
 	"github.com/syncthing/syncthing/lib/sync"
+	"github.com/thejerf/suture"
 )
 )
 
 
 func TestCSRFToken(t *testing.T) {
 func TestCSRFToken(t *testing.T) {
@@ -78,7 +78,7 @@ func TestStopAfterBrokenConfig(t *testing.T) {
 	srv.started = make(chan string)
 	srv.started = make(chan string)
 
 
 	sup := suture.New("test", suture.Spec{
 	sup := suture.New("test", suture.Spec{
-		PanicPanics: true,
+		PassThroughPanics: true,
 	})
 	})
 	sup.Add(srv)
 	sup.Add(srv)
 	sup.ServeBackground()
 	sup.ServeBackground()
@@ -490,7 +490,7 @@ func startHTTP(cfg *mockedConfig) (string, error) {
 
 
 	// Actually start the API service
 	// Actually start the API service
 	supervisor := suture.New("API test", suture.Spec{
 	supervisor := suture.New("API test", suture.Spec{
-		PanicPanics: true,
+		PassThroughPanics: true,
 	})
 	})
 	supervisor.Add(svc)
 	supervisor.Add(svc)
 	supervisor.ServeBackground()
 	supervisor.ServeBackground()

+ 2 - 2
cmd/syncthing/main.go

@@ -47,7 +47,7 @@ import (
 	"github.com/syncthing/syncthing/lib/tlsutil"
 	"github.com/syncthing/syncthing/lib/tlsutil"
 	"github.com/syncthing/syncthing/lib/upgrade"
 	"github.com/syncthing/syncthing/lib/upgrade"
 
 
-	"github.com/calmh/suture"
+	"github.com/thejerf/suture"
 
 
 	_ "net/http/pprof" // Need to import this to support STPROFILER.
 	_ "net/http/pprof" // Need to import this to support STPROFILER.
 )
 )
@@ -594,7 +594,7 @@ func syncthingMain(runtimeOptions RuntimeOptions) {
 		Log: func(line string) {
 		Log: func(line string) {
 			l.Debugln(line)
 			l.Debugln(line)
 		},
 		},
-		PanicPanics: true,
+		PassThroughPanics: true,
 	})
 	})
 	mainService.ServeBackground()
 	mainService.ServeBackground()
 
 

+ 2 - 2
cmd/syncthing/summaryservice.go

@@ -9,10 +9,10 @@ package main
 import (
 import (
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
 	"github.com/syncthing/syncthing/lib/events"
 	"github.com/syncthing/syncthing/lib/events"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/sync"
 	"github.com/syncthing/syncthing/lib/sync"
+	"github.com/thejerf/suture"
 )
 )
 
 
 // The folderSummaryService adds summary information events (FolderSummary and
 // The folderSummaryService adds summary information events (FolderSummary and
@@ -37,7 +37,7 @@ type folderSummaryService struct {
 func newFolderSummaryService(cfg configIntf, m modelIntf) *folderSummaryService {
 func newFolderSummaryService(cfg configIntf, m modelIntf) *folderSummaryService {
 	service := &folderSummaryService{
 	service := &folderSummaryService{
 		Supervisor: suture.New("folderSummaryService", suture.Spec{
 		Supervisor: suture.New("folderSummaryService", suture.Spec{
-			PanicPanics: true,
+			PassThroughPanics: true,
 		}),
 		}),
 		cfg:             cfg,
 		cfg:             cfg,
 		model:           m,
 		model:           m,

+ 1 - 1
lib/beacon/beacon.go

@@ -10,7 +10,7 @@ import (
 	"net"
 	"net"
 	stdsync "sync"
 	stdsync "sync"
 
 
-	"github.com/calmh/suture"
+	"github.com/thejerf/suture"
 )
 )
 
 
 type recv struct {
 type recv struct {

+ 2 - 2
lib/beacon/broadcast.go

@@ -11,8 +11,8 @@ import (
 	"net"
 	"net"
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
 	"github.com/syncthing/syncthing/lib/sync"
 	"github.com/syncthing/syncthing/lib/sync"
+	"github.com/thejerf/suture"
 )
 )
 
 
 type Broadcast struct {
 type Broadcast struct {
@@ -36,7 +36,7 @@ func NewBroadcast(port int) *Broadcast {
 			Log: func(line string) {
 			Log: func(line string) {
 				l.Debugln(line)
 				l.Debugln(line)
 			},
 			},
-			PanicPanics: true,
+			PassThroughPanics: true,
 		}),
 		}),
 		port:   port,
 		port:   port,
 		inbox:  make(chan []byte),
 		inbox:  make(chan []byte),

+ 2 - 2
lib/beacon/multicast.go

@@ -12,7 +12,7 @@ import (
 	"net"
 	"net"
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
+	"github.com/thejerf/suture"
 	"golang.org/x/net/ipv6"
 	"golang.org/x/net/ipv6"
 )
 )
 
 
@@ -36,7 +36,7 @@ func NewMulticast(addr string) *Multicast {
 			Log: func(line string) {
 			Log: func(line string) {
 				l.Debugln(line)
 				l.Debugln(line)
 			},
 			},
-			PanicPanics: true,
+			PassThroughPanics: true,
 		}),
 		}),
 		inbox:  make(chan []byte),
 		inbox:  make(chan []byte),
 		outbox: make(chan recv, 16),
 		outbox: make(chan recv, 16),

+ 5 - 5
lib/connections/service.go

@@ -30,7 +30,7 @@ import (
 	_ "github.com/syncthing/syncthing/lib/pmp"
 	_ "github.com/syncthing/syncthing/lib/pmp"
 	_ "github.com/syncthing/syncthing/lib/upnp"
 	_ "github.com/syncthing/syncthing/lib/upnp"
 
 
-	"github.com/calmh/suture"
+	"github.com/thejerf/suture"
 	"golang.org/x/time/rate"
 	"golang.org/x/time/rate"
 )
 )
 
 
@@ -105,7 +105,7 @@ func NewService(cfg *config.Wrapper, myID protocol.DeviceID, mdl Model, tlsCfg *
 			Log: func(line string) {
 			Log: func(line string) {
 				l.Infoln(line)
 				l.Infoln(line)
 			},
 			},
-			PanicPanics: true,
+			PassThroughPanics: true,
 		}),
 		}),
 		cfg:                  cfg,
 		cfg:                  cfg,
 		myID:                 myID,
 		myID:                 myID,
@@ -130,9 +130,9 @@ func NewService(cfg *config.Wrapper, myID protocol.DeviceID, mdl Model, tlsCfg *
 			Log: func(line string) {
 			Log: func(line string) {
 				l.Infoln(line)
 				l.Infoln(line)
 			},
 			},
-			FailureThreshold: 2,
-			FailureBackoff:   600 * time.Second,
-			PanicPanics:      true,
+			FailureThreshold:  2,
+			FailureBackoff:    600 * time.Second,
+			PassThroughPanics: true,
 		}),
 		}),
 	}
 	}
 	cfg.Subscribe(service)
 	cfg.Subscribe(service)

+ 2 - 2
lib/discover/cache.go

@@ -10,10 +10,10 @@ import (
 	stdsync "sync"
 	stdsync "sync"
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/sync"
 	"github.com/syncthing/syncthing/lib/sync"
 	"github.com/syncthing/syncthing/lib/util"
 	"github.com/syncthing/syncthing/lib/util"
+	"github.com/thejerf/suture"
 )
 )
 
 
 // The CachingMux aggregates results from multiple Finders. Each Finder has
 // The CachingMux aggregates results from multiple Finders. Each Finder has
@@ -52,7 +52,7 @@ type cachedError interface {
 func NewCachingMux() CachingMux {
 func NewCachingMux() CachingMux {
 	return &cachingMux{
 	return &cachingMux{
 		Supervisor: suture.New("discover.cachingMux", suture.Spec{
 		Supervisor: suture.New("discover.cachingMux", suture.Spec{
-			PanicPanics: true,
+			PassThroughPanics: true,
 		}),
 		}),
 		mut: sync.NewRWMutex(),
 		mut: sync.NewRWMutex(),
 	}
 	}

+ 1 - 1
lib/discover/discover.go

@@ -9,8 +9,8 @@ package discover
 import (
 import (
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/protocol"
+	"github.com/thejerf/suture"
 )
 )
 
 
 // A Finder provides lookup services of some kind.
 // A Finder provides lookup services of some kind.

+ 2 - 2
lib/discover/local.go

@@ -18,11 +18,11 @@ import (
 	"strconv"
 	"strconv"
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
 	"github.com/syncthing/syncthing/lib/beacon"
 	"github.com/syncthing/syncthing/lib/beacon"
 	"github.com/syncthing/syncthing/lib/events"
 	"github.com/syncthing/syncthing/lib/events"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/rand"
 	"github.com/syncthing/syncthing/lib/rand"
+	"github.com/thejerf/suture"
 )
 )
 
 
 type localClient struct {
 type localClient struct {
@@ -49,7 +49,7 @@ const (
 func NewLocal(id protocol.DeviceID, addr string, addrList AddressLister) (FinderService, error) {
 func NewLocal(id protocol.DeviceID, addr string, addrList AddressLister) (FinderService, error) {
 	c := &localClient{
 	c := &localClient{
 		Supervisor: suture.New("local", suture.Spec{
 		Supervisor: suture.New("local", suture.Spec{
-			PanicPanics: true,
+			PassThroughPanics: true,
 		}),
 		}),
 		myID:            id,
 		myID:            id,
 		addrList:        addrList,
 		addrList:        addrList,

+ 2 - 2
lib/model/model.go

@@ -22,7 +22,6 @@ import (
 	"strings"
 	"strings"
 	"time"
 	"time"
 
 
-	"github.com/calmh/suture"
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/connections"
 	"github.com/syncthing/syncthing/lib/connections"
 	"github.com/syncthing/syncthing/lib/db"
 	"github.com/syncthing/syncthing/lib/db"
@@ -36,6 +35,7 @@ import (
 	"github.com/syncthing/syncthing/lib/sync"
 	"github.com/syncthing/syncthing/lib/sync"
 	"github.com/syncthing/syncthing/lib/upgrade"
 	"github.com/syncthing/syncthing/lib/upgrade"
 	"github.com/syncthing/syncthing/lib/versioner"
 	"github.com/syncthing/syncthing/lib/versioner"
+	"github.com/thejerf/suture"
 )
 )
 
 
 var locationLocal *time.Location
 var locationLocal *time.Location
@@ -136,7 +136,7 @@ func NewModel(cfg *config.Wrapper, id protocol.DeviceID, clientName, clientVersi
 			Log: func(line string) {
 			Log: func(line string) {
 				l.Debugln(line)
 				l.Debugln(line)
 			},
 			},
-			PanicPanics: true,
+			PassThroughPanics: true,
 		}),
 		}),
 		cfg:                 cfg,
 		cfg:                 cfg,
 		db:                  ldb,
 		db:                  ldb,

+ 0 - 0
vendor/github.com/calmh/suture/LICENSE → vendor/github.com/thejerf/suture/LICENSE


+ 0 - 0
vendor/github.com/calmh/suture/doc.go → vendor/github.com/thejerf/suture/doc.go


+ 0 - 0
vendor/github.com/calmh/suture/messages.go → vendor/github.com/thejerf/suture/messages.go


+ 0 - 0
vendor/github.com/calmh/suture/service.go → vendor/github.com/thejerf/suture/service.go


+ 13 - 10
vendor/github.com/calmh/suture/supervisor.go → vendor/github.com/thejerf/suture/supervisor.go

@@ -126,15 +126,15 @@ type Supervisor struct {
 // Spec is used to pass arguments to the New function to create a
 // Spec is used to pass arguments to the New function to create a
 // supervisor. See the New function for full documentation.
 // supervisor. See the New function for full documentation.
 type Spec struct {
 type Spec struct {
-	Log              func(string)
-	FailureDecay     float64
-	FailureThreshold float64
-	FailureBackoff   time.Duration
-	Timeout          time.Duration
-	LogBadStop       BadStopLogger
-	LogFailure       FailureLogger
-	LogBackoff       BackoffLogger
-	PanicPanics      bool
+	Log               func(string)
+	FailureDecay      float64
+	FailureThreshold  float64
+	FailureBackoff    time.Duration
+	Timeout           time.Duration
+	LogBadStop        BadStopLogger
+	LogFailure        FailureLogger
+	LogBackoff        BackoffLogger
+	PassThroughPanics bool
 }
 }
 
 
 /*
 /*
@@ -178,6 +178,9 @@ failure count to zero.
 
 
 Timeout is how long Suture will wait for a service to properly terminate.
 Timeout is how long Suture will wait for a service to properly terminate.
 
 
+The PassThroughPanics options can be set to let panics in services propagate
+and crash the program, should this be desirable.
+
 */
 */
 func New(name string, spec Spec) (s *Supervisor) {
 func New(name string, spec Spec) (s *Supervisor) {
 	s = new(Supervisor)
 	s = new(Supervisor)
@@ -216,7 +219,7 @@ func New(name string, spec Spec) (s *Supervisor) {
 	} else {
 	} else {
 		s.timeout = spec.Timeout
 		s.timeout = spec.Timeout
 	}
 	}
-	s.recoverPanics = !spec.PanicPanics
+	s.recoverPanics = !spec.PassThroughPanics
 
 
 	// overriding these allows for testing the threshold behavior
 	// overriding these allows for testing the threshold behavior
 	s.getNow = time.Now
 	s.getNow = time.Now

+ 8 - 8
vendor/manifest

@@ -74,14 +74,6 @@
 			"branch": "master",
 			"branch": "master",
 			"notests": true
 			"notests": true
 		},
 		},
-		{
-			"importpath": "github.com/calmh/suture",
-			"repository": "https://github.com/calmh/suture",
-			"vcs": "git",
-			"revision": "2741a6bb8fdeba8f30c948c83756edc4dd21b9c6",
-			"branch": "master",
-			"notests": true
-		},
 		{
 		{
 			"importpath": "github.com/calmh/xdr",
 			"importpath": "github.com/calmh/xdr",
 			"repository": "https://github.com/calmh/xdr",
 			"repository": "https://github.com/calmh/xdr",
@@ -440,6 +432,14 @@
 			"branch": "master",
 			"branch": "master",
 			"notests": true
 			"notests": true
 		},
 		},
+		{
+			"importpath": "github.com/thejerf/suture",
+			"repository": "https://github.com/thejerf/suture",
+			"vcs": "git",
+			"revision": "bf6ee6a0b047ebbe9ae07d847f750dd18c6a9276",
+			"branch": "master",
+			"notests": true
+		},
 		{
 		{
 			"importpath": "github.com/tjfoc/gmsm/sm4",
 			"importpath": "github.com/tjfoc/gmsm/sm4",
 			"repository": "https://github.com/tjfoc/gmsm",
 			"repository": "https://github.com/tjfoc/gmsm",