From 29a911f1272985d6404f90e1ecb35ab9b01cfdb5 Mon Sep 17 00:00:00 2001 From: iknite Date: Tue, 18 Dec 2018 11:50:27 +0100 Subject: [PATCH] Derefernce MembershipTasks for sendAlert goroutine --- gossip/auditor/auditor.go | 2 +- gossip/monitor/monitor.go | 10 +++++----- gossip/publisher/publisher.go | 4 ++-- tests/e2e/setup.go | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gossip/auditor/auditor.go b/gossip/auditor/auditor.go index 5af3a8b76..ee56f3648 100644 --- a/gossip/auditor/auditor.go +++ b/gossip/auditor/auditor.go @@ -98,7 +98,7 @@ type MembershipTask struct { s *protocol.SignedSnapshot } -func (t *MembershipTask) Do() { +func (t MembershipTask) Do() { proof, err := t.qed.MembershipDigest(t.s.Snapshot.EventDigest, t.s.Snapshot.Version) if err != nil { // retry diff --git a/gossip/monitor/monitor.go b/gossip/monitor/monitor.go index 914631d2d..1943551df 100644 --- a/gossip/monitor/monitor.go +++ b/gossip/monitor/monitor.go @@ -48,7 +48,7 @@ type Monitor struct { client *client.HttpClient conf *Config - taskCh chan *QueryTask + taskCh chan QueryTask quitCh chan bool executionTicker *time.Ticker } @@ -60,7 +60,7 @@ func NewMonitor(conf *Config) (*Monitor, error) { monitor := &Monitor{ client: client, conf: conf, - taskCh: make(chan *QueryTask, 100), + taskCh: make(chan QueryTask, 100), quitCh: make(chan bool), } @@ -81,7 +81,7 @@ func (m Monitor) Process(b *protocol.BatchSnapshots) { log.Debugf("Processing batch from versions %d to %d", first.Version, last.Version) - task := &QueryTask{ + task := QueryTask{ Start: first.Version, End: last.Version, StartSnapshot: first, @@ -113,12 +113,12 @@ func (m *Monitor) Shutdown() { func (m *Monitor) dispatchTasks() { count := 0 - var task *QueryTask + var task QueryTask defer log.Debugf("%d tasks dispatched", count) for { select { case task = <-m.taskCh: - go m.executeTask(*task) + go m.executeTask(task) count++ default: return diff --git a/gossip/publisher/publisher.go b/gossip/publisher/publisher.go index 5441b255a..f355ae8dc 100644 --- a/gossip/publisher/publisher.go +++ b/gossip/publisher/publisher.go @@ -109,7 +109,7 @@ func (p *Publisher) dispatchTasks() { for { select { case task = <-p.taskCh: - go p.executeTask(&task) + go p.executeTask(task) count++ default: return @@ -120,7 +120,7 @@ func (p *Publisher) dispatchTasks() { } } -func (p *Publisher) executeTask(task *PublishTask) { +func (p *Publisher) executeTask(task PublishTask) { log.Debug("Executing task: %+v\n", task) buf, err := task.Batch.Encode() if err != nil { diff --git a/tests/e2e/setup.go b/tests/e2e/setup.go index d8a608b38..1579362e5 100644 --- a/tests/e2e/setup.go +++ b/tests/e2e/setup.go @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ + package e2e import (