Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Fix reading and writing of the results at the same time #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ outer:
if !ok {
break outer
}
result.Lock()
currentResult = *result
if firstTime && render {
clearLogo()
Expand All @@ -341,9 +342,7 @@ outer:
y = renderRegion(regionsData[region], y)
y++
}
}

if render {
y = 0
var percentDone float64
if test.Requests > 0 {
Expand All @@ -355,7 +354,7 @@ outer:

termbox.Flush()
}

result.Unlock()
case <-sigChan:
break outer
}
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ func (infra *AwsInfrastructure) Receive(results chan *result.LambdaResults) {
if lambdaResults != nil {
for _, lambdaResult := range lambdaResults {
lambdaAggregate := &data.Lambdas[lambdaResult.RunnerID]
data.Lock()
result.AddResult(lambdaAggregate, lambdaResult)
data.Unlock()
results <- data
}
if data.AllLambdasFinished() {
Expand Down
2 changes: 2 additions & 0 deletions result/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"math"
"sort"
"time"
"sync"

"github.com/goadapp/goad/api"
"github.com/goadapp/goad/goad/util"
Expand Down Expand Up @@ -31,6 +32,7 @@ type AggData struct {
// LambdaResults type
type LambdaResults struct {
Lambdas []AggData
sync.RWMutex
}

// Regions the LambdaResults were collected from
Expand Down