mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-04 03:48:07 +02:00
add deadlock mutex package
write to deadlock stderr after closing gocui more deadlock checking
This commit is contained in:
parent
7410acd1aa
commit
755ae0ef84
2
go.mod
2
go.mod
@ -30,6 +30,7 @@ require (
|
||||
github.com/sahilm/fuzzy v0.1.0
|
||||
github.com/samber/lo v1.10.1
|
||||
github.com/sanity-io/litter v1.5.2
|
||||
github.com/sasha-s/go-deadlock v0.3.1
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad
|
||||
github.com/stretchr/testify v1.7.0
|
||||
@ -58,6 +59,7 @@ require (
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/onsi/ginkgo v1.10.3 // indirect
|
||||
github.com/onsi/gomega v1.7.1 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
|
||||
github.com/rivo/uniseg v0.3.4 // indirect
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/xanzy/ssh-agent v0.2.1 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -125,6 +125,8 @@ github.com/onsi/ginkgo v1.10.3 h1:OoxbjfXVZyod1fmWYhI7SEyaD8B00ynP3T+D5GiyHOY=
|
||||
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@ -140,6 +142,8 @@ github.com/samber/lo v1.10.1 h1:0D3h7i0U3hRAbaCeQ82DLe67n0A7Bbl0/cEoWqFGp+U=
|
||||
github.com/samber/lo v1.10.1/go.mod h1:2I7tgIv8Q1SG2xEIkRq0F2i2zgxVpnyPOP0d3Gj2r+A=
|
||||
github.com/sanity-io/litter v1.5.2 h1:AnC8s9BMORWH5a4atZ4D6FPVvKGzHcnc5/IVTa87myw=
|
||||
github.com/sanity-io/litter v1.5.2/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0=
|
||||
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
|
||||
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
|
||||
gogit "github.com/jesseduffield/go-git/v5"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
||||
@ -57,7 +57,7 @@ func NewGitCommand(
|
||||
cmn *common.Common,
|
||||
osCommand *oscommands.OSCommand,
|
||||
gitConfig git_config.IGitConfig,
|
||||
syncMutex *sync.Mutex,
|
||||
syncMutex *deadlock.Mutex,
|
||||
) (*GitCommand, error) {
|
||||
if err := navigateToRepoRootDirectory(os.Stat, os.Chdir); err != nil {
|
||||
return nil, err
|
||||
@ -89,7 +89,7 @@ func NewGitCommandAux(
|
||||
gitConfig git_config.IGitConfig,
|
||||
dotGitDir string,
|
||||
repo *gogit.Repository,
|
||||
syncMutex *sync.Mutex,
|
||||
syncMutex *deadlock.Mutex,
|
||||
) *GitCommand {
|
||||
cmd := NewGitCmdObjBuilder(cmn.Log, osCommand.Cmd)
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package git_commands
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
gogit "github.com/jesseduffield/go-git/v5"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/common"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
type GitCommon struct {
|
||||
@ -16,7 +15,7 @@ type GitCommon struct {
|
||||
repo *gogit.Repository
|
||||
config *ConfigCommands
|
||||
// mutex for doing things like push/pull/fetch
|
||||
syncMutex *sync.Mutex
|
||||
syncMutex *deadlock.Mutex
|
||||
}
|
||||
|
||||
func NewGitCommon(
|
||||
@ -26,7 +25,7 @@ func NewGitCommon(
|
||||
dotGitDir string,
|
||||
repo *gogit.Repository,
|
||||
config *ConfigCommands,
|
||||
syncMutex *sync.Mutex,
|
||||
syncMutex *deadlock.Mutex,
|
||||
) *GitCommon {
|
||||
return &GitCommon{
|
||||
Common: cmn,
|
||||
|
@ -3,7 +3,6 @@ package commands
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -12,6 +11,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/git_config"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -220,7 +220,7 @@ func TestNewGitCommand(t *testing.T) {
|
||||
NewGitCommand(utils.NewDummyCommon(),
|
||||
oscommands.NewDummyOSCommand(),
|
||||
git_config.NewFakeGitConfig(nil),
|
||||
&sync.Mutex{},
|
||||
&deadlock.Mutex{},
|
||||
))
|
||||
})
|
||||
}
|
||||
|
@ -2,7 +2,8 @@ package oscommands
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"sync"
|
||||
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
// A command object is a general way to represent a command to be run on the
|
||||
@ -51,8 +52,8 @@ type ICmdObj interface {
|
||||
PromptOnCredentialRequest() ICmdObj
|
||||
FailOnCredentialRequest() ICmdObj
|
||||
|
||||
WithMutex(mutex *sync.Mutex) ICmdObj
|
||||
Mutex() *sync.Mutex
|
||||
WithMutex(mutex *deadlock.Mutex) ICmdObj
|
||||
Mutex() *deadlock.Mutex
|
||||
|
||||
GetCredentialStrategy() CredentialStrategy
|
||||
}
|
||||
@ -76,7 +77,7 @@ type CmdObj struct {
|
||||
credentialStrategy CredentialStrategy
|
||||
|
||||
// can be set so that we don't run certain commands simultaneously
|
||||
mutex *sync.Mutex
|
||||
mutex *deadlock.Mutex
|
||||
}
|
||||
|
||||
type CredentialStrategy int
|
||||
@ -139,11 +140,11 @@ func (self *CmdObj) IgnoreEmptyError() ICmdObj {
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *CmdObj) Mutex() *sync.Mutex {
|
||||
func (self *CmdObj) Mutex() *deadlock.Mutex {
|
||||
return self.mutex
|
||||
}
|
||||
|
||||
func (self *CmdObj) WithMutex(mutex *sync.Mutex) ICmdObj {
|
||||
func (self *CmdObj) WithMutex(mutex *deadlock.Mutex) ICmdObj {
|
||||
self.mutex = mutex
|
||||
|
||||
return self
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
|
||||
type Buffer struct {
|
||||
b bytes.Buffer
|
||||
m sync.Mutex
|
||||
m deadlock.Mutex
|
||||
}
|
||||
|
||||
func (b *Buffer) Read(p []byte) (n int, err error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
// statusManager's job is to handle rendering of loading states and toast notifications
|
||||
@ -13,7 +13,7 @@ import (
|
||||
type statusManager struct {
|
||||
statuses []appStatus
|
||||
nextId int
|
||||
mutex sync.Mutex
|
||||
mutex deadlock.Mutex
|
||||
}
|
||||
|
||||
type appStatus struct {
|
||||
|
@ -2,7 +2,6 @@ package context
|
||||
|
||||
import (
|
||||
"math"
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts"
|
||||
@ -14,7 +13,7 @@ type MergeConflictsContext struct {
|
||||
types.Context
|
||||
viewModel *ConflictsViewModel
|
||||
c *types.HelperCommon
|
||||
mutex *sync.Mutex
|
||||
mutex *deadlock.Mutex
|
||||
}
|
||||
|
||||
type ConflictsViewModel struct {
|
||||
@ -40,7 +39,7 @@ func NewMergeConflictsContext(
|
||||
|
||||
return &MergeConflictsContext{
|
||||
viewModel: viewModel,
|
||||
mutex: &sync.Mutex{},
|
||||
mutex: &deadlock.Mutex{},
|
||||
Context: NewSimpleContext(
|
||||
NewBaseContext(NewBaseContextOpts{
|
||||
Kind: types.MAIN_CONTEXT,
|
||||
@ -64,7 +63,7 @@ func (self *MergeConflictsContext) SetState(state *mergeconflicts.State) {
|
||||
self.viewModel.state = state
|
||||
}
|
||||
|
||||
func (self *MergeConflictsContext) GetMutex() *sync.Mutex {
|
||||
func (self *MergeConflictsContext) GetMutex() *deadlock.Mutex {
|
||||
return self.mutex
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/patch_exploring"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
deadlock "github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
type PatchExplorerContext struct {
|
||||
@ -15,7 +14,7 @@ type PatchExplorerContext struct {
|
||||
viewTrait *ViewTrait
|
||||
getIncludedLineIndices func() []int
|
||||
c *types.HelperCommon
|
||||
mutex *sync.Mutex
|
||||
mutex *deadlock.Mutex
|
||||
}
|
||||
|
||||
var _ types.IPatchExplorerContext = (*PatchExplorerContext)(nil)
|
||||
@ -35,7 +34,7 @@ func NewPatchExplorerContext(
|
||||
state: nil,
|
||||
viewTrait: NewViewTrait(view),
|
||||
c: c,
|
||||
mutex: &sync.Mutex{},
|
||||
mutex: &deadlock.Mutex{},
|
||||
getIncludedLineIndices: getIncludedLineIndices,
|
||||
SimpleContext: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
|
||||
View: view,
|
||||
@ -124,6 +123,6 @@ func (self *PatchExplorerContext) NavigateTo(isFocused bool, selectedLineIdx int
|
||||
return self.RenderAndFocus(isFocused)
|
||||
}
|
||||
|
||||
func (self *PatchExplorerContext) GetMutex() *sync.Mutex {
|
||||
func (self *PatchExplorerContext) GetMutex() *deadlock.Mutex {
|
||||
return self.mutex
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
"github.com/jesseduffield/lazygit/pkg/updates"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
"gopkg.in/ozeidan/fuzzy-patricia.v3/patricia"
|
||||
)
|
||||
|
||||
@ -358,13 +359,13 @@ func NewGui(
|
||||
// sake of backwards compatibility. We're making use of short circuiting here
|
||||
ShowExtrasWindow: cmn.UserConfig.Gui.ShowCommandLog && !config.GetAppState().HideCommandLog,
|
||||
Mutexes: types.Mutexes{
|
||||
RefreshingFilesMutex: &sync.Mutex{},
|
||||
RefreshingStatusMutex: &sync.Mutex{},
|
||||
SyncMutex: &sync.Mutex{},
|
||||
LocalCommitsMutex: &sync.Mutex{},
|
||||
SubprocessMutex: &sync.Mutex{},
|
||||
PopupMutex: &sync.Mutex{},
|
||||
PtyMutex: &sync.Mutex{},
|
||||
RefreshingFilesMutex: &deadlock.Mutex{},
|
||||
RefreshingStatusMutex: &deadlock.Mutex{},
|
||||
SyncMutex: &deadlock.Mutex{},
|
||||
LocalCommitsMutex: &deadlock.Mutex{},
|
||||
SubprocessMutex: &deadlock.Mutex{},
|
||||
PopupMutex: &deadlock.Mutex{},
|
||||
PtyMutex: &deadlock.Mutex{},
|
||||
},
|
||||
InitialDir: initialDir,
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package popup
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/common"
|
||||
@ -10,12 +9,13 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
type PopupHandler struct {
|
||||
*common.Common
|
||||
index int
|
||||
sync.Mutex
|
||||
deadlock.Mutex
|
||||
createPopupPanelFn func(types.CreatePopupPanelOpts) error
|
||||
onErrorFn func() error
|
||||
popContextFn func() error
|
||||
|
@ -2,7 +2,6 @@ package presentation
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/generics/set"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
||||
@ -14,6 +13,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/kyokomi/emoji/v2"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
type pipeSetCacheKey struct {
|
||||
@ -23,7 +23,7 @@ type pipeSetCacheKey struct {
|
||||
|
||||
var (
|
||||
pipeSetCache = make(map[pipeSetCacheKey][][]*graph.Pipe)
|
||||
mutex sync.Mutex
|
||||
mutex deadlock.Mutex
|
||||
)
|
||||
|
||||
type bisectBounds struct {
|
||||
|
@ -1,13 +1,12 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/common"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
"gopkg.in/ozeidan/fuzzy-patricia.v3/patricia"
|
||||
)
|
||||
|
||||
@ -160,11 +159,11 @@ type Model struct {
|
||||
// if you add a new mutex here be sure to instantiate it. We're using pointers to
|
||||
// mutexes so that we can pass the mutexes to controllers.
|
||||
type Mutexes struct {
|
||||
RefreshingFilesMutex *sync.Mutex
|
||||
RefreshingStatusMutex *sync.Mutex
|
||||
SyncMutex *sync.Mutex
|
||||
LocalCommitsMutex *sync.Mutex
|
||||
SubprocessMutex *sync.Mutex
|
||||
PopupMutex *sync.Mutex
|
||||
PtyMutex *sync.Mutex
|
||||
RefreshingFilesMutex *deadlock.Mutex
|
||||
RefreshingStatusMutex *deadlock.Mutex
|
||||
SyncMutex *deadlock.Mutex
|
||||
LocalCommitsMutex *deadlock.Mutex
|
||||
SubprocessMutex *deadlock.Mutex
|
||||
PopupMutex *deadlock.Mutex
|
||||
PtyMutex *deadlock.Mutex
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/patch_exploring"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
type ContextKind int
|
||||
@ -106,7 +105,7 @@ type IPatchExplorerContext interface {
|
||||
Focus() error
|
||||
GetContentToRender(isFocused bool) string
|
||||
NavigateTo(isFocused bool, selectedLineIdx int) error
|
||||
GetMutex() *sync.Mutex
|
||||
GetMutex() *deadlock.Mutex
|
||||
}
|
||||
|
||||
type IViewTrait interface {
|
||||
|
@ -1,9 +1,8 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
// the purpose of an AsyncHandler is to ensure that if we have multiple long-running
|
||||
@ -17,13 +16,13 @@ import (
|
||||
type AsyncHandler struct {
|
||||
currentId int
|
||||
lastId int
|
||||
mutex sync.Mutex
|
||||
mutex deadlock.Mutex
|
||||
onReject func()
|
||||
}
|
||||
|
||||
func NewAsyncHandler() *AsyncHandler {
|
||||
return &AsyncHandler{
|
||||
mutex: sync.Mutex{},
|
||||
mutex: deadlock.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -34,8 +35,8 @@ type ViewBufferManager struct {
|
||||
// this is what we write the output of the task to. It's typically a view
|
||||
writer io.Writer
|
||||
|
||||
waitingMutex sync.Mutex
|
||||
taskIDMutex sync.Mutex
|
||||
waitingMutex deadlock.Mutex
|
||||
taskIDMutex deadlock.Mutex
|
||||
Log *logrus.Entry
|
||||
newTaskID int
|
||||
readLines chan int
|
||||
@ -126,7 +127,7 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p
|
||||
}
|
||||
})
|
||||
|
||||
loadingMutex := sync.Mutex{}
|
||||
loadingMutex := deadlock.Mutex{}
|
||||
|
||||
// not sure if it's the right move to redefine this or not
|
||||
self.readLines = make(chan int, 1024)
|
||||
|
31
pkg/utils/once_writer.go
Normal file
31
pkg/utils/once_writer.go
Normal file
@ -0,0 +1,31 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// This wraps a writer and ensures that before we actually write anything we call a given function first
|
||||
|
||||
type OnceWriter struct {
|
||||
writer io.Writer
|
||||
once sync.Once
|
||||
f func()
|
||||
}
|
||||
|
||||
var _ io.Writer = &OnceWriter{}
|
||||
|
||||
func NewOnceWriter(writer io.Writer, f func()) *OnceWriter {
|
||||
return &OnceWriter{
|
||||
writer: writer,
|
||||
f: f,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *OnceWriter) Write(p []byte) (n int, err error) {
|
||||
self.once.Do(func() {
|
||||
self.f()
|
||||
})
|
||||
|
||||
return self.writer.Write(p)
|
||||
}
|
19
pkg/utils/once_writer_test.go
Normal file
19
pkg/utils/once_writer_test.go
Normal file
@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestOnceWriter(t *testing.T) {
|
||||
innerWriter := bytes.NewBuffer(nil)
|
||||
counter := 0
|
||||
onceWriter := NewOnceWriter(innerWriter, func() {
|
||||
counter += 1
|
||||
})
|
||||
_, _ = onceWriter.Write([]byte("hello"))
|
||||
_, _ = onceWriter.Write([]byte("hello"))
|
||||
if counter != 1 {
|
||||
t.Errorf("expected counter to be 1, got %d", counter)
|
||||
}
|
||||
}
|
4
vendor/github.com/petermattis/goid/.gitignore
generated
vendored
Normal file
4
vendor/github.com/petermattis/goid/.gitignore
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*~
|
||||
*.test
|
||||
.*.swp
|
||||
.DS_Store
|
202
vendor/github.com/petermattis/goid/LICENSE
generated
vendored
Normal file
202
vendor/github.com/petermattis/goid/LICENSE
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
5
vendor/github.com/petermattis/goid/README.md
generated
vendored
Normal file
5
vendor/github.com/petermattis/goid/README.md
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# goid [![Build Status](https://travis-ci.org/petermattis/goid.svg?branch=master)](https://travis-ci.org/petermattis/goid)
|
||||
|
||||
Programatically retrieve the current goroutine's ID. See [the CI
|
||||
configuration](.travis.yml) for supported Go versions. In addition,
|
||||
gccgo 7.2.1 (Go 1.8.3) is supported.
|
35
vendor/github.com/petermattis/goid/goid.go
generated
vendored
Normal file
35
vendor/github.com/petermattis/goid/goid.go
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 2016 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
package goid
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"runtime"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func ExtractGID(s []byte) int64 {
|
||||
s = s[len("goroutine "):]
|
||||
s = s[:bytes.IndexByte(s, ' ')]
|
||||
gid, _ := strconv.ParseInt(string(s), 10, 64)
|
||||
return gid
|
||||
}
|
||||
|
||||
// Parse the goid from runtime.Stack() output. Slow, but it works.
|
||||
func getSlow() int64 {
|
||||
var buf [64]byte
|
||||
return ExtractGID(buf[:runtime.Stack(buf[:], false)])
|
||||
}
|
25
vendor/github.com/petermattis/goid/goid_gccgo.go
generated
vendored
Normal file
25
vendor/github.com/petermattis/goid/goid_gccgo.go
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2018 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// +build gccgo
|
||||
|
||||
package goid
|
||||
|
||||
//extern runtime.getg
|
||||
func getg() *g
|
||||
|
||||
func Get() int64 {
|
||||
return getg().goid
|
||||
}
|
23
vendor/github.com/petermattis/goid/goid_go1.3.c
generated
vendored
Normal file
23
vendor/github.com/petermattis/goid/goid_go1.3.c
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2015 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// +build !go1.4
|
||||
|
||||
#include <runtime.h>
|
||||
|
||||
void ·Get(int64 ret) {
|
||||
ret = g->goid;
|
||||
USED(&ret);
|
||||
}
|
21
vendor/github.com/petermattis/goid/goid_go1.3.go
generated
vendored
Normal file
21
vendor/github.com/petermattis/goid/goid_go1.3.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2015 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// +build !go1.4
|
||||
|
||||
package goid
|
||||
|
||||
// Get returns the id of the current goroutine.
|
||||
func Get() int64
|
34
vendor/github.com/petermattis/goid/goid_go1.4.go
generated
vendored
Normal file
34
vendor/github.com/petermattis/goid/goid_go1.4.go
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright 2015 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// +build go1.4,!go1.5
|
||||
|
||||
package goid
|
||||
|
||||
import "unsafe"
|
||||
|
||||
var pointerSize = unsafe.Sizeof(uintptr(0))
|
||||
|
||||
// Backdoor access to runtime·getg().
|
||||
func getg() uintptr // in goid_go1.4.s
|
||||
|
||||
// Get returns the id of the current goroutine.
|
||||
func Get() int64 {
|
||||
// The goid is the 16th field in the G struct where each field is a
|
||||
// pointer, uintptr or padded to that size. See runtime.h from the
|
||||
// Go sources. I'm not aware of a cleaner way to determine the
|
||||
// offset.
|
||||
return *(*int64)(unsafe.Pointer(getg() + 16*pointerSize))
|
||||
}
|
18
vendor/github.com/petermattis/goid/goid_go1.4.s
generated
vendored
Normal file
18
vendor/github.com/petermattis/goid/goid_go1.4.s
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Assembly to get into package runtime without using exported symbols.
|
||||
// See https://github.com/golang/go/blob/release-branch.go1.4/misc/cgo/test/backdoor/thunk.s
|
||||
|
||||
// +build amd64 amd64p32 arm 386
|
||||
// +build go1.4,!go1.5
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
#ifdef GOARCH_arm
|
||||
#define JMP B
|
||||
#endif
|
||||
|
||||
TEXT ·getg(SB),NOSPLIT,$0-0
|
||||
JMP runtime·getg(SB)
|
21
vendor/github.com/petermattis/goid/goid_go1.5_amd64.go
generated
vendored
Normal file
21
vendor/github.com/petermattis/goid/goid_go1.5_amd64.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2016 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// +build amd64 amd64p32
|
||||
// +build gc,go1.5
|
||||
|
||||
package goid
|
||||
|
||||
func Get() int64
|
29
vendor/github.com/petermattis/goid/goid_go1.5_amd64.s
generated
vendored
Normal file
29
vendor/github.com/petermattis/goid/goid_go1.5_amd64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2016 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// Assembly to mimic runtime.getg.
|
||||
|
||||
// +build amd64 amd64p32
|
||||
// +build gc,go1.5
|
||||
|
||||
#include "go_asm.h"
|
||||
#include "textflag.h"
|
||||
|
||||
// func Get() int64
|
||||
TEXT ·Get(SB),NOSPLIT,$0-8
|
||||
MOVQ (TLS), R14
|
||||
MOVQ g_goid(R14), R13
|
||||
MOVQ R13, ret+0(FP)
|
||||
RET
|
26
vendor/github.com/petermattis/goid/goid_go1.5_arm.go
generated
vendored
Normal file
26
vendor/github.com/petermattis/goid/goid_go1.5_arm.go
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2016 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// +build arm
|
||||
// +build gc,go1.5
|
||||
|
||||
package goid
|
||||
|
||||
// Backdoor access to runtime·getg().
|
||||
func getg() *g // in goid_go1.5plus.s
|
||||
|
||||
func Get() int64 {
|
||||
return getg().goid
|
||||
}
|
27
vendor/github.com/petermattis/goid/goid_go1.5_arm.s
generated
vendored
Normal file
27
vendor/github.com/petermattis/goid/goid_go1.5_arm.s
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2016 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// Assembly to mimic runtime.getg.
|
||||
// This should work on arm64 as well, but it hasn't been tested.
|
||||
|
||||
// +build arm
|
||||
// +build gc,go1.5
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func getg() *g
|
||||
TEXT ·getg(SB),NOSPLIT,$0-8
|
||||
MOVW g, ret+0(FP)
|
||||
RET
|
23
vendor/github.com/petermattis/goid/goid_slow.go
generated
vendored
Normal file
23
vendor/github.com/petermattis/goid/goid_slow.go
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2016 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// +build go1.4,!go1.5,!amd64,!amd64p32,!arm,!386 go1.5,!go1.6,!amd64,!amd64p32,!arm go1.6,!amd64,!amd64p32,!arm go1.9,!amd64,!amd64p32,!arm
|
||||
|
||||
package goid
|
||||
|
||||
// Get returns the id of the current goroutine.
|
||||
func Get() int64 {
|
||||
return getSlow()
|
||||
}
|
16
vendor/github.com/petermattis/goid/runtime_gccgo_go1.8.go
generated
vendored
Normal file
16
vendor/github.com/petermattis/goid/runtime_gccgo_go1.8.go
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// +build gccgo,go1.8
|
||||
|
||||
package goid
|
||||
|
||||
// https://github.com/gcc-mirror/gcc/blob/gcc-7-branch/libgo/go/runtime/runtime2.go#L329-L422
|
||||
|
||||
type g struct {
|
||||
_panic uintptr
|
||||
_defer uintptr
|
||||
m uintptr
|
||||
syscallsp uintptr
|
||||
syscallpc uintptr
|
||||
param uintptr
|
||||
atomicstatus uint32
|
||||
goid int64 // Here it is!
|
||||
}
|
56
vendor/github.com/petermattis/goid/runtime_go1.5.go
generated
vendored
Normal file
56
vendor/github.com/petermattis/goid/runtime_go1.5.go
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright 2016 Peter Mattis.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License. See the AUTHORS file
|
||||
// for names of contributors.
|
||||
|
||||
// +build go1.5,!go1.6
|
||||
|
||||
package goid
|
||||
|
||||
// Just enough of the structs from runtime/runtime2.go to get the offset to goid.
|
||||
// See https://github.com/golang/go/blob/release-branch.go1.5/src/runtime/runtime2.go
|
||||
|
||||
type stack struct {
|
||||
lo uintptr
|
||||
hi uintptr
|
||||
}
|
||||
|
||||
type gobuf struct {
|
||||
sp uintptr
|
||||
pc uintptr
|
||||
g uintptr
|
||||
ctxt uintptr
|
||||
ret uintptr
|
||||
lr uintptr
|
||||
bp uintptr
|
||||
}
|
||||
|
||||
type g struct {
|
||||
stack stack
|
||||
stackguard0 uintptr
|
||||
stackguard1 uintptr
|
||||
|
||||
_panic uintptr
|
||||
_defer uintptr
|
||||
m uintptr
|
||||
stackAlloc uintptr
|
||||
sched gobuf
|
||||
syscallsp uintptr
|
||||
syscallpc uintptr
|
||||
stkbar []uintptr
|
||||
stkbarPos uintptr
|
||||
param uintptr
|
||||
atomicstatus uint32
|
||||
stackLock uint32
|
||||
goid int64 // Here it is!
|
||||
}
|
42
vendor/github.com/petermattis/goid/runtime_go1.6.go
generated
vendored
Normal file
42
vendor/github.com/petermattis/goid/runtime_go1.6.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
// +build gc,go1.6,!go1.9
|
||||
|
||||
package goid
|
||||
|
||||
// Just enough of the structs from runtime/runtime2.go to get the offset to goid.
|
||||
// See https://github.com/golang/go/blob/release-branch.go1.6/src/runtime/runtime2.go
|
||||
|
||||
type stack struct {
|
||||
lo uintptr
|
||||
hi uintptr
|
||||
}
|
||||
|
||||
type gobuf struct {
|
||||
sp uintptr
|
||||
pc uintptr
|
||||
g uintptr
|
||||
ctxt uintptr
|
||||
ret uintptr
|
||||
lr uintptr
|
||||
bp uintptr
|
||||
}
|
||||
|
||||
type g struct {
|
||||
stack stack
|
||||
stackguard0 uintptr
|
||||
stackguard1 uintptr
|
||||
|
||||
_panic uintptr
|
||||
_defer uintptr
|
||||
m uintptr
|
||||
stackAlloc uintptr
|
||||
sched gobuf
|
||||
syscallsp uintptr
|
||||
syscallpc uintptr
|
||||
stkbar []uintptr
|
||||
stkbarPos uintptr
|
||||
stktopsp uintptr
|
||||
param uintptr
|
||||
atomicstatus uint32
|
||||
stackLock uint32
|
||||
goid int64 // Here it is!
|
||||
}
|
36
vendor/github.com/petermattis/goid/runtime_go1.9.go
generated
vendored
Normal file
36
vendor/github.com/petermattis/goid/runtime_go1.9.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// +build gc,go1.9
|
||||
|
||||
package goid
|
||||
|
||||
type stack struct {
|
||||
lo uintptr
|
||||
hi uintptr
|
||||
}
|
||||
|
||||
type gobuf struct {
|
||||
sp uintptr
|
||||
pc uintptr
|
||||
g uintptr
|
||||
ctxt uintptr
|
||||
ret uintptr
|
||||
lr uintptr
|
||||
bp uintptr
|
||||
}
|
||||
|
||||
type g struct {
|
||||
stack stack
|
||||
stackguard0 uintptr
|
||||
stackguard1 uintptr
|
||||
|
||||
_panic uintptr
|
||||
_defer uintptr
|
||||
m uintptr
|
||||
sched gobuf
|
||||
syscallsp uintptr
|
||||
syscallpc uintptr
|
||||
stktopsp uintptr
|
||||
param uintptr
|
||||
atomicstatus uint32
|
||||
stackLock uint32
|
||||
goid int64 // Here it is!
|
||||
}
|
201
vendor/github.com/sasha-s/go-deadlock/LICENSE
generated
vendored
Normal file
201
vendor/github.com/sasha-s/go-deadlock/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
187
vendor/github.com/sasha-s/go-deadlock/Readme.md
generated
vendored
Normal file
187
vendor/github.com/sasha-s/go-deadlock/Readme.md
generated
vendored
Normal file
@ -0,0 +1,187 @@
|
||||
# Online deadlock detection in go (golang). [![Try it online](https://img.shields.io/badge/try%20it-online-blue.svg)](https://wandbox.org/permlink/hJc6QCZowxbNm9WW) [![Docs](https://godoc.org/github.com/sasha-s/go-deadlock?status.svg)](https://godoc.org/github.com/sasha-s/go-deadlock) [![Build Status](https://travis-ci.org/sasha-s/go-deadlock.svg?branch=master)](https://travis-ci.org/sasha-s/go-deadlock) [![codecov](https://codecov.io/gh/sasha-s/go-deadlock/branch/master/graph/badge.svg)](https://codecov.io/gh/sasha-s/go-deadlock) [![version](https://badge.fury.io/gh/sasha-s%2Fgo-deadlock.svg)](https://github.com/sasha-s/go-deadlock/releases) [![Go Report Card](https://goreportcard.com/badge/github.com/sasha-s/go-deadlock)](https://goreportcard.com/report/github.com/sasha-s/go-deadlock) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
## Why
|
||||
Deadlocks happen and are painful to debug.
|
||||
|
||||
## What
|
||||
go-deadlock provides (RW)Mutex drop-in replacements for sync.(RW)Mutex.
|
||||
It would not work if you create a spaghetti of channels.
|
||||
Mutexes only.
|
||||
|
||||
## Installation
|
||||
```sh
|
||||
go get github.com/sasha-s/go-deadlock/...
|
||||
```
|
||||
|
||||
## Usage
|
||||
```go
|
||||
import "github.com/sasha-s/go-deadlock"
|
||||
var mu deadlock.Mutex
|
||||
// Use normally, it works exactly like sync.Mutex does.
|
||||
mu.Lock()
|
||||
|
||||
defer mu.Unlock()
|
||||
// Or
|
||||
var rw deadlock.RWMutex
|
||||
rw.RLock()
|
||||
defer rw.RUnlock()
|
||||
```
|
||||
|
||||
### Deadlocks
|
||||
One of the most common sources of deadlocks is inconsistent lock ordering:
|
||||
say, you have two mutexes A and B, and in some goroutines you have
|
||||
```go
|
||||
A.Lock() // defer A.Unlock() or similar.
|
||||
...
|
||||
B.Lock() // defer B.Unlock() or similar.
|
||||
```
|
||||
And in another goroutine the order of locks is reversed:
|
||||
```go
|
||||
B.Lock() // defer B.Unlock() or similar.
|
||||
...
|
||||
A.Lock() // defer A.Unlock() or similar.
|
||||
```
|
||||
|
||||
Another common sources of deadlocks is duplicate take a lock in a goroutine:
|
||||
```
|
||||
A.Rlock() or lock()
|
||||
|
||||
A.lock() or A.RLock()
|
||||
```
|
||||
|
||||
This does not guarantee a deadlock (maybe the goroutines above can never be running at the same time), but it usually a design flaw at least.
|
||||
|
||||
go-deadlock can detect such cases (unless you cross goroutine boundary - say lock A, then spawn a goroutine, block until it is singals, and lock B inside of the goroutine), even if the deadlock itself happens very infrequently and is painful to reproduce!
|
||||
|
||||
Each time go-deadlock sees a lock attempt for lock B, it records the order A before B, for each lock that is currently being held in the same goroutine, and it prints (and exits the program by default) when it sees the locking order being violated.
|
||||
|
||||
In addition, if it sees that we are waiting on a lock for a long time (opts.DeadlockTimeout, 30 seconds by default), it reports a potential deadlock, also printing the stacktrace for a goroutine that is currently holding the lock we are desperately trying to grab.
|
||||
|
||||
|
||||
## Sample output
|
||||
#### Inconsistent lock ordering:
|
||||
```
|
||||
POTENTIAL DEADLOCK: Inconsistent locking. saw this ordering in one goroutine:
|
||||
happened before
|
||||
inmem.go:623 bttest.(*server).ReadModifyWriteRow { r.mu.Lock() } <<<<<
|
||||
inmem_test.go:118 bttest.TestConcurrentMutationsReadModifyAndGC.func4 { _, _ = s.ReadModifyWriteRow(ctx, rmw()) }
|
||||
|
||||
happened after
|
||||
inmem.go:629 bttest.(*server).ReadModifyWriteRow { tbl.mu.RLock() } <<<<<
|
||||
inmem_test.go:118 bttest.TestConcurrentMutationsReadModifyAndGC.func4 { _, _ = s.ReadModifyWriteRow(ctx, rmw()) }
|
||||
|
||||
in another goroutine: happened before
|
||||
inmem.go:799 bttest.(*table).gc { t.mu.RLock() } <<<<<
|
||||
inmem_test.go:125 bttest.TestConcurrentMutationsReadModifyAndGC.func5 { tbl.gc() }
|
||||
|
||||
happend after
|
||||
inmem.go:814 bttest.(*table).gc { r.mu.Lock() } <<<<<
|
||||
inmem_test.go:125 bttest.TestConcurrentMutationsReadModifyAndGC.func5 { tbl.gc() }
|
||||
```
|
||||
|
||||
#### Waiting for a lock for a long time:
|
||||
|
||||
```
|
||||
POTENTIAL DEADLOCK:
|
||||
Previous place where the lock was grabbed
|
||||
goroutine 240 lock 0xc820160440
|
||||
inmem.go:799 bttest.(*table).gc { t.mu.RLock() } <<<<<
|
||||
inmem_test.go:125 bttest.TestConcurrentMutationsReadModifyAndGC.func5 { tbl.gc() }
|
||||
|
||||
Have been trying to lock it again for more than 40ms
|
||||
goroutine 68 lock 0xc820160440
|
||||
inmem.go:785 bttest.(*table).mutableRow { t.mu.Lock() } <<<<<
|
||||
inmem.go:428 bttest.(*server).MutateRow { r := tbl.mutableRow(string(req.RowKey)) }
|
||||
inmem_test.go:111 bttest.TestConcurrentMutationsReadModifyAndGC.func3 { s.MutateRow(ctx, req) }
|
||||
|
||||
|
||||
Here is what goroutine 240 doing now
|
||||
goroutine 240 [select]:
|
||||
github.com/sasha-s/go-deadlock.lock(0xc82028ca10, 0x5189e0, 0xc82013a9b0)
|
||||
/Users/sasha/go/src/github.com/sasha-s/go-deadlock/deadlock.go:163 +0x1640
|
||||
github.com/sasha-s/go-deadlock.(*Mutex).Lock(0xc82013a9b0)
|
||||
/Users/sasha/go/src/github.com/sasha-s/go-deadlock/deadlock.go:54 +0x86
|
||||
google.golang.org/cloud/bigtable/bttest.(*table).gc(0xc820160440)
|
||||
/Users/sasha/go/src/google.golang.org/cloud/bigtable/bttest/inmem.go:814 +0x28d
|
||||
google.golang.org/cloud/bigtable/bttest.TestConcurrentMutationsReadModifyAndGC.func5(0xc82015c760, 0xc820160440) /Users/sasha/go/src/google.golang.org/cloud/bigtable/bttest/inmem_test.go:125 +0x48
|
||||
created by google.golang.org/cloud/bigtable/bttest.TestConcurrentMutationsReadModifyAndGC
|
||||
/Users/sasha/go/src/google.golang.org/cloud/bigtable/bttest/inmem_test.go:126 +0xb6f
|
||||
```
|
||||
|
||||
## Used in
|
||||
[cockroachdb: Potential deadlock between Gossip.SetStorage and Node.gossipStores](https://github.com/cockroachdb/cockroach/issues/7972)
|
||||
|
||||
[bigtable/bttest: A race between GC and row mutations](https://code-review.googlesource.com#/c/5301/)
|
||||
|
||||
## Need a mutex that works with net.context?
|
||||
I have [one](https://github.com/sasha-s/go-csync).
|
||||
|
||||
## Grabbing an RLock twice from the same goroutine
|
||||
This is, surprisingly, not a good idea!
|
||||
|
||||
From [RWMutex](https://golang.org/pkg/sync/#RWMutex) docs:
|
||||
|
||||
>If a goroutine holds a RWMutex for reading and another goroutine might call Lock, no goroutine should expect to be able to acquire a read lock until the initial read lock is released. In particular, this prohibits recursive read locking. This is to ensure that the lock eventually becomes available; a blocked Lock call excludes new readers from acquiring the lock.
|
||||
|
||||
|
||||
The following code will deadlock — [run the example on playground](https://play.golang.org/p/AkL-W63nq5f) or [try it online with go-deadlock on wandbox](https://wandbox.org/permlink/JwnL0GMySBju4SII):
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var mu sync.RWMutex
|
||||
|
||||
chrlockTwice := make(chan struct{}) // Used to control rlockTwice
|
||||
rlockTwice := func() {
|
||||
mu.RLock()
|
||||
fmt.Println("first Rlock succeeded")
|
||||
<-chrlockTwice
|
||||
<-chrlockTwice
|
||||
fmt.Println("trying to Rlock again")
|
||||
mu.RLock()
|
||||
fmt.Println("second Rlock succeeded")
|
||||
mu.RUnlock()
|
||||
mu.RUnlock()
|
||||
}
|
||||
|
||||
chLock := make(chan struct{}) // Used to contol lock
|
||||
lock := func() {
|
||||
<-chLock
|
||||
fmt.Println("about to Lock")
|
||||
mu.Lock()
|
||||
fmt.Println("Lock succeeded")
|
||||
mu.Unlock()
|
||||
<-chLock
|
||||
}
|
||||
|
||||
control := func() {
|
||||
chrlockTwice <- struct{}{}
|
||||
chLock <- struct{}{}
|
||||
|
||||
close(chrlockTwice)
|
||||
close(chLock)
|
||||
}
|
||||
|
||||
go control()
|
||||
go lock()
|
||||
rlockTwice()
|
||||
}
|
||||
```
|
||||
## Configuring go-deadlock
|
||||
|
||||
Have a look at [Opts](https://pkg.go.dev/github.com/sasha-s/go-deadlock#pkg-variables).
|
||||
|
||||
* `Opts.Disable`: disables deadlock detection altogether
|
||||
* `Opts.DisableLockOrderDetection`: disables lock order based deadlock detection.
|
||||
* `Opts.DeadlockTimeout`: blocking on mutex for longer than DeadlockTimeout is considered a deadlock. ignored if negative
|
||||
* `Opts.OnPotentialDeadlock`: callback for then deadlock is detected
|
||||
* `Opts.MaxMapSize`: size of happens before // happens after table
|
||||
* `Opts.PrintAllCurrentGoroutines`: dump stacktraces of all goroutines when inconsistent locking is detected, verbose
|
||||
* `Opts.LogBuf`: where to write deadlock info/stacktraces
|
||||
|
||||
|
363
vendor/github.com/sasha-s/go-deadlock/deadlock.go
generated
vendored
Normal file
363
vendor/github.com/sasha-s/go-deadlock/deadlock.go
generated
vendored
Normal file
@ -0,0 +1,363 @@
|
||||
package deadlock
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/petermattis/goid"
|
||||
)
|
||||
|
||||
// Opts control how deadlock detection behaves.
|
||||
// Options are supposed to be set once at a startup (say, when parsing flags).
|
||||
var Opts = struct {
|
||||
// Mutex/RWMutex would work exactly as their sync counterparts
|
||||
// -- almost no runtime penalty, no deadlock detection if Disable == true.
|
||||
Disable bool
|
||||
// Would disable lock order based deadlock detection if DisableLockOrderDetection == true.
|
||||
DisableLockOrderDetection bool
|
||||
// Waiting for a lock for longer than DeadlockTimeout is considered a deadlock.
|
||||
// Ignored is DeadlockTimeout <= 0.
|
||||
DeadlockTimeout time.Duration
|
||||
// OnPotentialDeadlock is called each time a potential deadlock is detected -- either based on
|
||||
// lock order or on lock wait time.
|
||||
OnPotentialDeadlock func()
|
||||
// Will keep MaxMapSize lock pairs (happens before // happens after) in the map.
|
||||
// The map resets once the threshold is reached.
|
||||
MaxMapSize int
|
||||
// Will dump stacktraces of all goroutines when inconsistent locking is detected.
|
||||
PrintAllCurrentGoroutines bool
|
||||
mu *sync.Mutex // Protects the LogBuf.
|
||||
// Will print deadlock info to log buffer.
|
||||
LogBuf io.Writer
|
||||
}{
|
||||
DeadlockTimeout: time.Second * 30,
|
||||
OnPotentialDeadlock: func() {
|
||||
os.Exit(2)
|
||||
},
|
||||
MaxMapSize: 1024 * 64,
|
||||
mu: &sync.Mutex{},
|
||||
LogBuf: os.Stderr,
|
||||
}
|
||||
|
||||
// Cond is sync.Cond wrapper
|
||||
type Cond struct {
|
||||
sync.Cond
|
||||
}
|
||||
|
||||
// Locker is sync.Locker wrapper
|
||||
type Locker struct {
|
||||
sync.Locker
|
||||
}
|
||||
|
||||
// Once is sync.Once wrapper
|
||||
type Once struct {
|
||||
sync.Once
|
||||
}
|
||||
|
||||
// Pool is sync.Poll wrapper
|
||||
type Pool struct {
|
||||
sync.Pool
|
||||
}
|
||||
|
||||
// WaitGroup is sync.WaitGroup wrapper
|
||||
type WaitGroup struct {
|
||||
sync.WaitGroup
|
||||
}
|
||||
|
||||
// A Mutex is a drop-in replacement for sync.Mutex.
|
||||
// Performs deadlock detection unless disabled in Opts.
|
||||
type Mutex struct {
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// Lock locks the mutex.
|
||||
// If the lock is already in use, the calling goroutine
|
||||
// blocks until the mutex is available.
|
||||
//
|
||||
// Unless deadlock detection is disabled, logs potential deadlocks to Opts.LogBuf,
|
||||
// calling Opts.OnPotentialDeadlock on each occasion.
|
||||
func (m *Mutex) Lock() {
|
||||
lock(m.mu.Lock, m)
|
||||
}
|
||||
|
||||
// Unlock unlocks the mutex.
|
||||
// It is a run-time error if m is not locked on entry to Unlock.
|
||||
//
|
||||
// A locked Mutex is not associated with a particular goroutine.
|
||||
// It is allowed for one goroutine to lock a Mutex and then
|
||||
// arrange for another goroutine to unlock it.
|
||||
func (m *Mutex) Unlock() {
|
||||
m.mu.Unlock()
|
||||
if !Opts.Disable {
|
||||
postUnlock(m)
|
||||
}
|
||||
}
|
||||
|
||||
// An RWMutex is a drop-in replacement for sync.RWMutex.
|
||||
// Performs deadlock detection unless disabled in Opts.
|
||||
type RWMutex struct {
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// Lock locks rw for writing.
|
||||
// If the lock is already locked for reading or writing,
|
||||
// Lock blocks until the lock is available.
|
||||
// To ensure that the lock eventually becomes available,
|
||||
// a blocked Lock call excludes new readers from acquiring
|
||||
// the lock.
|
||||
//
|
||||
// Unless deadlock detection is disabled, logs potential deadlocks to Opts.LogBuf,
|
||||
// calling Opts.OnPotentialDeadlock on each occasion.
|
||||
func (m *RWMutex) Lock() {
|
||||
lock(m.mu.Lock, m)
|
||||
}
|
||||
|
||||
// Unlock unlocks the mutex for writing. It is a run-time error if rw is
|
||||
// not locked for writing on entry to Unlock.
|
||||
//
|
||||
// As with Mutexes, a locked RWMutex is not associated with a particular
|
||||
// goroutine. One goroutine may RLock (Lock) an RWMutex and then
|
||||
// arrange for another goroutine to RUnlock (Unlock) it.
|
||||
func (m *RWMutex) Unlock() {
|
||||
m.mu.Unlock()
|
||||
if !Opts.Disable {
|
||||
postUnlock(m)
|
||||
}
|
||||
}
|
||||
|
||||
// RLock locks the mutex for reading.
|
||||
//
|
||||
// Unless deadlock detection is disabled, logs potential deadlocks to Opts.LogBuf,
|
||||
// calling Opts.OnPotentialDeadlock on each occasion.
|
||||
func (m *RWMutex) RLock() {
|
||||
lock(m.mu.RLock, m)
|
||||
}
|
||||
|
||||
// RUnlock undoes a single RLock call;
|
||||
// it does not affect other simultaneous readers.
|
||||
// It is a run-time error if rw is not locked for reading
|
||||
// on entry to RUnlock.
|
||||
func (m *RWMutex) RUnlock() {
|
||||
m.mu.RUnlock()
|
||||
if !Opts.Disable {
|
||||
postUnlock(m)
|
||||
}
|
||||
}
|
||||
|
||||
// RLocker returns a Locker interface that implements
|
||||
// the Lock and Unlock methods by calling RLock and RUnlock.
|
||||
func (m *RWMutex) RLocker() sync.Locker {
|
||||
return (*rlocker)(m)
|
||||
}
|
||||
|
||||
func preLock(stack []uintptr, p interface{}) {
|
||||
lo.preLock(stack, p)
|
||||
}
|
||||
|
||||
func postLock(stack []uintptr, p interface{}) {
|
||||
lo.postLock(stack, p)
|
||||
}
|
||||
|
||||
func postUnlock(p interface{}) {
|
||||
lo.postUnlock(p)
|
||||
}
|
||||
|
||||
func lock(lockFn func(), ptr interface{}) {
|
||||
if Opts.Disable {
|
||||
lockFn()
|
||||
return
|
||||
}
|
||||
stack := callers(1)
|
||||
preLock(stack, ptr)
|
||||
if Opts.DeadlockTimeout <= 0 {
|
||||
lockFn()
|
||||
} else {
|
||||
ch := make(chan struct{})
|
||||
currentID := goid.Get()
|
||||
go func() {
|
||||
for {
|
||||
t := time.NewTimer(Opts.DeadlockTimeout)
|
||||
defer t.Stop() // This runs after the losure finishes, but it's OK.
|
||||
select {
|
||||
case <-t.C:
|
||||
lo.mu.Lock()
|
||||
prev, ok := lo.cur[ptr]
|
||||
if !ok {
|
||||
lo.mu.Unlock()
|
||||
break // Nobody seems to be holding the lock, try again.
|
||||
}
|
||||
Opts.mu.Lock()
|
||||
fmt.Fprintln(Opts.LogBuf, header)
|
||||
fmt.Fprintln(Opts.LogBuf, "Previous place where the lock was grabbed")
|
||||
fmt.Fprintf(Opts.LogBuf, "goroutine %v lock %p\n", prev.gid, ptr)
|
||||
printStack(Opts.LogBuf, prev.stack)
|
||||
fmt.Fprintln(Opts.LogBuf, "Have been trying to lock it again for more than", Opts.DeadlockTimeout)
|
||||
fmt.Fprintf(Opts.LogBuf, "goroutine %v lock %p\n", currentID, ptr)
|
||||
printStack(Opts.LogBuf, stack)
|
||||
stacks := stacks()
|
||||
grs := bytes.Split(stacks, []byte("\n\n"))
|
||||
for _, g := range grs {
|
||||
if goid.ExtractGID(g) == prev.gid {
|
||||
fmt.Fprintln(Opts.LogBuf, "Here is what goroutine", prev.gid, "doing now")
|
||||
Opts.LogBuf.Write(g)
|
||||
fmt.Fprintln(Opts.LogBuf)
|
||||
}
|
||||
}
|
||||
lo.other(ptr)
|
||||
if Opts.PrintAllCurrentGoroutines {
|
||||
fmt.Fprintln(Opts.LogBuf, "All current goroutines:")
|
||||
Opts.LogBuf.Write(stacks)
|
||||
}
|
||||
fmt.Fprintln(Opts.LogBuf)
|
||||
if buf, ok := Opts.LogBuf.(*bufio.Writer); ok {
|
||||
buf.Flush()
|
||||
}
|
||||
Opts.mu.Unlock()
|
||||
lo.mu.Unlock()
|
||||
Opts.OnPotentialDeadlock()
|
||||
<-ch
|
||||
return
|
||||
case <-ch:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
lockFn()
|
||||
postLock(stack, ptr)
|
||||
close(ch)
|
||||
return
|
||||
}
|
||||
postLock(stack, ptr)
|
||||
}
|
||||
|
||||
type lockOrder struct {
|
||||
mu sync.Mutex
|
||||
cur map[interface{}]stackGID // stacktraces + gids for the locks currently taken.
|
||||
order map[beforeAfter]ss // expected order of locks.
|
||||
}
|
||||
|
||||
type stackGID struct {
|
||||
stack []uintptr
|
||||
gid int64
|
||||
}
|
||||
|
||||
type beforeAfter struct {
|
||||
before interface{}
|
||||
after interface{}
|
||||
}
|
||||
|
||||
type ss struct {
|
||||
before []uintptr
|
||||
after []uintptr
|
||||
}
|
||||
|
||||
var lo = newLockOrder()
|
||||
|
||||
func newLockOrder() *lockOrder {
|
||||
return &lockOrder{
|
||||
cur: map[interface{}]stackGID{},
|
||||
order: map[beforeAfter]ss{},
|
||||
}
|
||||
}
|
||||
|
||||
func (l *lockOrder) postLock(stack []uintptr, p interface{}) {
|
||||
gid := goid.Get()
|
||||
l.mu.Lock()
|
||||
l.cur[p] = stackGID{stack, gid}
|
||||
l.mu.Unlock()
|
||||
}
|
||||
|
||||
func (l *lockOrder) preLock(stack []uintptr, p interface{}) {
|
||||
if Opts.DisableLockOrderDetection {
|
||||
return
|
||||
}
|
||||
gid := goid.Get()
|
||||
l.mu.Lock()
|
||||
for b, bs := range l.cur {
|
||||
if b == p {
|
||||
if bs.gid == gid {
|
||||
Opts.mu.Lock()
|
||||
fmt.Fprintln(Opts.LogBuf, header, "Recursive locking:")
|
||||
fmt.Fprintf(Opts.LogBuf, "current goroutine %d lock %p\n", gid, b)
|
||||
printStack(Opts.LogBuf, stack)
|
||||
fmt.Fprintln(Opts.LogBuf, "Previous place where the lock was grabbed (same goroutine)")
|
||||
printStack(Opts.LogBuf, bs.stack)
|
||||
l.other(p)
|
||||
if buf, ok := Opts.LogBuf.(*bufio.Writer); ok {
|
||||
buf.Flush()
|
||||
}
|
||||
Opts.mu.Unlock()
|
||||
Opts.OnPotentialDeadlock()
|
||||
}
|
||||
continue
|
||||
}
|
||||
if bs.gid != gid { // We want locks taken in the same goroutine only.
|
||||
continue
|
||||
}
|
||||
if s, ok := l.order[beforeAfter{p, b}]; ok {
|
||||
Opts.mu.Lock()
|
||||
fmt.Fprintln(Opts.LogBuf, header, "Inconsistent locking. saw this ordering in one goroutine:")
|
||||
fmt.Fprintln(Opts.LogBuf, "happened before")
|
||||
printStack(Opts.LogBuf, s.before)
|
||||
fmt.Fprintln(Opts.LogBuf, "happened after")
|
||||
printStack(Opts.LogBuf, s.after)
|
||||
fmt.Fprintln(Opts.LogBuf, "in another goroutine: happened before")
|
||||
printStack(Opts.LogBuf, bs.stack)
|
||||
fmt.Fprintln(Opts.LogBuf, "happened after")
|
||||
printStack(Opts.LogBuf, stack)
|
||||
l.other(p)
|
||||
fmt.Fprintln(Opts.LogBuf)
|
||||
if buf, ok := Opts.LogBuf.(*bufio.Writer); ok {
|
||||
buf.Flush()
|
||||
}
|
||||
Opts.mu.Unlock()
|
||||
Opts.OnPotentialDeadlock()
|
||||
}
|
||||
l.order[beforeAfter{b, p}] = ss{bs.stack, stack}
|
||||
if len(l.order) == Opts.MaxMapSize { // Reset the map to keep memory footprint bounded.
|
||||
l.order = map[beforeAfter]ss{}
|
||||
}
|
||||
}
|
||||
l.mu.Unlock()
|
||||
}
|
||||
|
||||
func (l *lockOrder) postUnlock(p interface{}) {
|
||||
l.mu.Lock()
|
||||
delete(l.cur, p)
|
||||
l.mu.Unlock()
|
||||
}
|
||||
|
||||
type rlocker RWMutex
|
||||
|
||||
func (r *rlocker) Lock() { (*RWMutex)(r).RLock() }
|
||||
func (r *rlocker) Unlock() { (*RWMutex)(r).RUnlock() }
|
||||
|
||||
// Under lo.mu Locked.
|
||||
func (l *lockOrder) other(ptr interface{}) {
|
||||
empty := true
|
||||
for k := range l.cur {
|
||||
if k == ptr {
|
||||
continue
|
||||
}
|
||||
empty = false
|
||||
}
|
||||
if empty {
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(Opts.LogBuf, "Other goroutines holding locks:")
|
||||
for k, pp := range l.cur {
|
||||
if k == ptr {
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(Opts.LogBuf, "goroutine %v lock %p\n", pp.gid, k)
|
||||
printStack(Opts.LogBuf, pp.stack)
|
||||
}
|
||||
fmt.Fprintln(Opts.LogBuf)
|
||||
}
|
||||
|
||||
const header = "POTENTIAL DEADLOCK:"
|
10
vendor/github.com/sasha-s/go-deadlock/deadlock_map.go
generated
vendored
Normal file
10
vendor/github.com/sasha-s/go-deadlock/deadlock_map.go
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
// +build go1.9
|
||||
|
||||
package deadlock
|
||||
|
||||
import "sync"
|
||||
|
||||
// Map is sync.Map wrapper
|
||||
type Map struct {
|
||||
sync.Map
|
||||
}
|
107
vendor/github.com/sasha-s/go-deadlock/stacktraces.go
generated
vendored
Normal file
107
vendor/github.com/sasha-s/go-deadlock/stacktraces.go
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
package deadlock
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func callers(skip int) []uintptr {
|
||||
s := make([]uintptr, 50) // Most relevant context seem to appear near the top of the stack.
|
||||
return s[:runtime.Callers(2+skip, s)]
|
||||
}
|
||||
|
||||
func printStack(w io.Writer, stack []uintptr) {
|
||||
home := os.Getenv("HOME")
|
||||
usr, err := user.Current()
|
||||
if err == nil {
|
||||
home = usr.HomeDir
|
||||
}
|
||||
cwd, _ := os.Getwd()
|
||||
|
||||
for i, pc := range stack {
|
||||
f := runtime.FuncForPC(pc)
|
||||
name := f.Name()
|
||||
pkg := ""
|
||||
if pos := strings.LastIndex(name, "/"); pos >= 0 {
|
||||
name = name[pos+1:]
|
||||
}
|
||||
if pos := strings.Index(name, "."); pos >= 0 {
|
||||
pkg = name[:pos]
|
||||
name = name[pos+1:]
|
||||
}
|
||||
file, line := f.FileLine(pc)
|
||||
if (pkg == "runtime" && name == "goexit") || (pkg == "testing" && name == "tRunner") {
|
||||
fmt.Fprintln(w)
|
||||
return
|
||||
}
|
||||
tail := ""
|
||||
if i == 0 {
|
||||
tail = " <<<<<" // Make the line performing a lock prominent.
|
||||
}
|
||||
// Shorten the file name.
|
||||
clean := file
|
||||
if cwd != "" {
|
||||
cl, err := filepath.Rel(cwd, file)
|
||||
if err == nil {
|
||||
clean = cl
|
||||
}
|
||||
}
|
||||
if home != "" {
|
||||
s2 := strings.Replace(file, home, "~", 1)
|
||||
if len(clean) > len(s2) {
|
||||
clean = s2
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(w, "%s:%d %s.%s %s%s\n", clean, line-1, pkg, name, code(file, line), tail)
|
||||
}
|
||||
fmt.Fprintln(w)
|
||||
}
|
||||
|
||||
var fileSources struct {
|
||||
sync.Mutex
|
||||
lines map[string][][]byte
|
||||
}
|
||||
|
||||
// Reads souce file lines from disk if not cached already.
|
||||
func getSourceLines(file string) [][]byte {
|
||||
fileSources.Lock()
|
||||
defer fileSources.Unlock()
|
||||
if fileSources.lines == nil {
|
||||
fileSources.lines = map[string][][]byte{}
|
||||
}
|
||||
if lines, ok := fileSources.lines[file]; ok {
|
||||
return lines
|
||||
}
|
||||
text, _ := ioutil.ReadFile(file)
|
||||
fileSources.lines[file] = bytes.Split(text, []byte{'\n'})
|
||||
return fileSources.lines[file]
|
||||
}
|
||||
|
||||
func code(file string, line int) string {
|
||||
lines := getSourceLines(file)
|
||||
line -= 2
|
||||
if line >= len(lines) || line < 0 {
|
||||
return "???"
|
||||
}
|
||||
return "{ " + string(bytes.TrimSpace(lines[line])) + " }"
|
||||
}
|
||||
|
||||
// Stacktraces for all goroutines.
|
||||
func stacks() []byte {
|
||||
buf := make([]byte, 1024*16)
|
||||
for {
|
||||
n := runtime.Stack(buf, true)
|
||||
if n < len(buf) {
|
||||
return buf[:n]
|
||||
}
|
||||
buf = make([]byte, 2*len(buf))
|
||||
}
|
||||
}
|
12
vendor/github.com/sasha-s/go-deadlock/test.sh
generated
vendored
Normal file
12
vendor/github.com/sasha-s/go-deadlock/test.sh
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
echo "" > coverage.txt
|
||||
|
||||
for d in $(go list ./...); do
|
||||
go test -coverprofile=profile.out -covermode=atomic "$d"
|
||||
if [ -f profile.out ]; then
|
||||
cat profile.out >> coverage.txt
|
||||
rm profile.out
|
||||
fi
|
||||
done
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -225,6 +225,7 @@ github.com/mitchellh/go-homedir
|
||||
## explicit
|
||||
# github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5
|
||||
## explicit
|
||||
github.com/petermattis/goid
|
||||
# github.com/pmezard/go-difflib v1.0.0
|
||||
## explicit
|
||||
github.com/pmezard/go-difflib/difflib
|
||||
@ -242,6 +243,7 @@ github.com/samber/lo
|
||||
github.com/sanity-io/litter
|
||||
# github.com/sasha-s/go-deadlock v0.3.1
|
||||
## explicit
|
||||
github.com/sasha-s/go-deadlock
|
||||
# github.com/sergi/go-diff v1.1.0
|
||||
## explicit; go 1.12
|
||||
github.com/sergi/go-diff/diffmatchpatch
|
||||
|
Loading…
Reference in New Issue
Block a user