diff options
| author | Shulhan <ms@kilabit.info> | 2021-04-09 19:43:12 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-04-09 19:43:12 +0700 |
| commit | 64928cfedb9faea524b1be3cbf9018d02d00d82a (patch) | |
| tree | 1a3e5276c5a56a2246eb010ca12535aa6f7b778f | |
| parent | 9d741226536b21e53b0ac78d7585539af67a2398 (diff) | |
| download | gorankusu-64928cfedb9faea524b1be3cbf9018d02d00d82a.tar.xz | |
all: check for nil PreAttack when on worker attack queue
If the HttpTarget.PreAttack is not set we should not call it.
While at it, reset the RunRequest result to nil at the end of attack.
| -rw-r--r-- | trunks.go | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -623,7 +623,9 @@ func (trunks *Trunks) workerAttackQueue() { var err error trunks.Env.AttackRunning = rr - rr.HttpTarget.PreAttack(rr) + if rr.HttpTarget.PreAttack != nil { + rr.HttpTarget.PreAttack(rr) + } isCancelled := false attacker := vegeta.NewAttacker( @@ -663,7 +665,7 @@ func (trunks *Trunks) workerAttackQueue() { trunks.cancelq <- true } } else { - err := rr.result.finish() + err = rr.result.finish() if err != nil { mlog.Errf("%s %s: %s\n", logp, rr.result.Name, err) } @@ -677,6 +679,7 @@ func (trunks *Trunks) workerAttackQueue() { mlog.Outf("%s: %s finished.\n", logp, rr.result.Name) } + rr.result = nil trunks.Env.AttackRunning = nil } } |
