mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 19:50:18 +00:00
优化代码退出的逻辑, 防止结果无法正确输出, 或管道无法正确关闭
This commit is contained in:
parent
1895496e0b
commit
2399c4ff5c
@ -52,7 +52,6 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) {
|
||||
return pool.buildPathRequest(s)
|
||||
}
|
||||
pool.check = func() {
|
||||
pool.wg.Add(1)
|
||||
_ = pool.pool.Invoke(newUnit(pkg.RandPath(), CheckSource))
|
||||
|
||||
if pool.failedCount > pool.BreakThreshold {
|
||||
@ -67,7 +66,6 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) {
|
||||
}
|
||||
|
||||
pool.check = func() {
|
||||
pool.wg.Add(1)
|
||||
_ = pool.pool.Invoke(newUnit(pkg.RandHost(), CheckSource))
|
||||
|
||||
if pool.failedCount > pool.BreakThreshold {
|
||||
@ -83,7 +81,6 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) {
|
||||
req, err := pool.genReq(unit.path)
|
||||
if err != nil {
|
||||
logs.Log.Error(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var bl *pkg.Baseline
|
||||
@ -148,7 +145,6 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) {
|
||||
pool.bar.Done()
|
||||
}
|
||||
|
||||
pool.wg.Done()
|
||||
})
|
||||
|
||||
pool.pool = p
|
||||
@ -160,6 +156,7 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) {
|
||||
}
|
||||
} else {
|
||||
pool.BaseCompare(bl)
|
||||
pool.wg.Done()
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,6 +257,7 @@ Loop:
|
||||
break Loop
|
||||
}
|
||||
}
|
||||
//p.wg.Add(100)
|
||||
p.wg.Wait()
|
||||
p.Close()
|
||||
}
|
||||
@ -363,7 +361,7 @@ func (p *Pool) recover() {
|
||||
}
|
||||
|
||||
func (p *Pool) Close() {
|
||||
for !p.analyzeDone {
|
||||
for p.analyzeDone {
|
||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
}
|
||||
close(p.tempCh)
|
||||
|
@ -159,7 +159,11 @@ func (r *Runner) Outputting() {
|
||||
|
||||
for {
|
||||
select {
|
||||
case bl := <-r.OutputCh:
|
||||
case bl, ok := <-r.OutputCh:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
if bl.IsValid {
|
||||
outFunc(bl)
|
||||
} else {
|
||||
@ -172,7 +176,10 @@ func (r *Runner) Outputting() {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case bl := <-r.FuzzyCh:
|
||||
case bl, ok := <-r.FuzzyCh:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if r.Fuzzy {
|
||||
logs.Log.Console("[baseline.fuzzy] " + bl.String() + "\n")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user