Compare commits

..

No commits in common. "master" and "v0.1.9" have entirely different histories.

4 changed files with 9 additions and 23 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 jar3b
Copyright (c) 2019 jar3b
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

4
go.mod
View File

@ -1,5 +1,5 @@
module github.com/jar3b/grawt
go 1.16
go 1.15
require github.com/sirupsen/logrus v1.8.1
require github.com/sirupsen/logrus v1.7.0

4
go.sum
View File

@ -2,8 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=

View File

@ -13,20 +13,7 @@ type Waiter struct {
blockingMode bool
waitGroup sync.WaitGroup
closeHandlers []*CloseHandler
haltingFlag bool
haltingMutex sync.RWMutex
}
func (w *Waiter) isHalting() bool {
w.haltingMutex.RLock()
defer w.haltingMutex.RUnlock()
return w.haltingFlag
}
func (w *Waiter) setHalting(value bool) {
w.haltingMutex.Lock()
defer w.haltingMutex.Unlock()
w.haltingFlag = value
isHalting bool
}
func (w *Waiter) addHandler(f *func(), autoDone bool) *CloseHandler {
@ -76,10 +63,10 @@ func (w *Waiter) AddCloseHandler(f func(), waitForChannel bool) *CloseHandler {
}
func (w *Waiter) Halt(err error) {
if w.isHalting() {
if w.isHalting {
return
}
w.setHalting(true)
w.isHalting = true
w.RLock()
for _, h := range w.closeHandlers {
@ -100,7 +87,7 @@ func (w *Waiter) Halt(err error) {
}
}
w.setHalting(false)
w.isHalting = false
}
func (w *Waiter) Wait() {
@ -122,7 +109,6 @@ func NewWaiter() *Waiter {
sync.WaitGroup{},
make([]*CloseHandler, 0),
false,
sync.RWMutex{},
}
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)