mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 10:33:11 -06:00
Lint errors
This commit is contained in:
parent
7630d11cde
commit
07ed00379b
|
|
@ -162,7 +162,7 @@ func (oq *destinationQueue) sendEDU(event *gomatrixserverlib.EDU, receipt *share
|
||||||
// requests to retry.
|
// requests to retry.
|
||||||
func (oq *destinationQueue) wakeQueueIfNeeded() {
|
func (oq *destinationQueue) wakeQueueIfNeeded() {
|
||||||
// If we are backing off then interrupt the backoff.
|
// If we are backing off then interrupt the backoff.
|
||||||
if oq.backingOff.CAS(true, false) {
|
if oq.backingOff.CompareAndSwap(true, false) {
|
||||||
oq.interruptBackoff <- true
|
oq.interruptBackoff <- true
|
||||||
}
|
}
|
||||||
// If we aren't running then wake up the queue.
|
// If we aren't running then wake up the queue.
|
||||||
|
|
@ -242,7 +242,7 @@ func (oq *destinationQueue) getPendingFromDatabase() {
|
||||||
func (oq *destinationQueue) backgroundSend() {
|
func (oq *destinationQueue) backgroundSend() {
|
||||||
// Check if a worker is already running, and if it isn't, then
|
// Check if a worker is already running, and if it isn't, then
|
||||||
// mark it as started.
|
// mark it as started.
|
||||||
if !oq.running.CAS(false, true) {
|
if !oq.running.CompareAndSwap(false, true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
destinationQueueRunning.Inc()
|
destinationQueueRunning.Inc()
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ func (s *ServerStatistics) Failure() (time.Time, bool) {
|
||||||
// a new backoff period. Increase the failure counter and
|
// a new backoff period. Increase the failure counter and
|
||||||
// start a goroutine which will wait out the backoff and
|
// start a goroutine which will wait out the backoff and
|
||||||
// unset the backoffStarted flag when done.
|
// unset the backoffStarted flag when done.
|
||||||
if s.backoffStarted.CAS(false, true) {
|
if s.backoffStarted.CompareAndSwap(false, true) {
|
||||||
if s.backoffCount.Inc() >= s.statistics.FailuresUntilBlacklist {
|
if s.backoffCount.Inc() >= s.statistics.FailuresUntilBlacklist {
|
||||||
s.blacklisted.Store(true)
|
s.blacklisted.Store(true)
|
||||||
if s.statistics.DB != nil {
|
if s.statistics.DB != nil {
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@ func IsUniqueConstraintViolationErr(err error) bool {
|
||||||
switch e := err.(type) {
|
switch e := err.(type) {
|
||||||
case *pq.Error:
|
case *pq.Error:
|
||||||
return e.Code == "23505"
|
return e.Code == "23505"
|
||||||
case pq.Error:
|
|
||||||
return e.Code == "23505"
|
|
||||||
case *sqlite3.Error:
|
case *sqlite3.Error:
|
||||||
return e.Code == sqlite3.ErrConstraint
|
return e.Code == sqlite3.ErrConstraint
|
||||||
case sqlite3.Error:
|
case sqlite3.Error:
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ func (w *ExclusiveWriter) Do(db *sql.DB, txn *sql.Tx, f func(txn *sql.Tx) error)
|
||||||
// opened using the database object from the task and then this will
|
// opened using the database object from the task and then this will
|
||||||
// be passed as a parameter to the task function.
|
// be passed as a parameter to the task function.
|
||||||
func (w *ExclusiveWriter) run() {
|
func (w *ExclusiveWriter) run() {
|
||||||
if !w.running.CAS(false, true) {
|
if !w.running.CompareAndSwap(false, true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if tracingEnabled {
|
if tracingEnabled {
|
||||||
|
|
|
||||||
|
|
@ -498,7 +498,7 @@ func (b *BaseDendrite) SetupAndServeHTTP(
|
||||||
logrus.Infof("Starting internal %s listener on %s", b.componentName, internalServ.Addr)
|
logrus.Infof("Starting internal %s listener on %s", b.componentName, internalServ.Addr)
|
||||||
b.ProcessContext.ComponentStarted()
|
b.ProcessContext.ComponentStarted()
|
||||||
internalServ.RegisterOnShutdown(func() {
|
internalServ.RegisterOnShutdown(func() {
|
||||||
if internalShutdown.CAS(false, true) {
|
if internalShutdown.CompareAndSwap(false, true) {
|
||||||
b.ProcessContext.ComponentFinished()
|
b.ProcessContext.ComponentFinished()
|
||||||
logrus.Infof("Stopped internal HTTP listener")
|
logrus.Infof("Stopped internal HTTP listener")
|
||||||
}
|
}
|
||||||
|
|
@ -526,7 +526,7 @@ func (b *BaseDendrite) SetupAndServeHTTP(
|
||||||
logrus.Infof("Starting external %s listener on %s", b.componentName, externalServ.Addr)
|
logrus.Infof("Starting external %s listener on %s", b.componentName, externalServ.Addr)
|
||||||
b.ProcessContext.ComponentStarted()
|
b.ProcessContext.ComponentStarted()
|
||||||
externalServ.RegisterOnShutdown(func() {
|
externalServ.RegisterOnShutdown(func() {
|
||||||
if externalShutdown.CAS(false, true) {
|
if externalShutdown.CompareAndSwap(false, true) {
|
||||||
b.ProcessContext.ComponentFinished()
|
b.ProcessContext.ComponentFinished()
|
||||||
logrus.Infof("Stopped external HTTP listener")
|
logrus.Infof("Stopped external HTTP listener")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func (b *ProcessContext) WaitForComponentsToFinish() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *ProcessContext) Degraded() {
|
func (b *ProcessContext) Degraded() {
|
||||||
if b.degraded.CAS(false, true) {
|
if b.degraded.CompareAndSwap(false, true) {
|
||||||
logrus.Warn("Dendrite is running in a degraded state")
|
logrus.Warn("Dendrite is running in a degraded state")
|
||||||
sentry.CaptureException(fmt.Errorf("Process is running in a degraded state"))
|
sentry.CaptureException(fmt.Errorf("Process is running in a degraded state"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue