mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
修复程序并发调度失败的bug
This commit is contained in:
parent
e3fc74e78d
commit
c84440a662
@ -210,33 +210,41 @@ func (pool *Pool) Run(ctx context.Context, offset, limit int) {
|
|||||||
go pool.doCommonFile()
|
go pool.doCommonFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
closeCh := make(chan struct{})
|
||||||
for {
|
//go func() {
|
||||||
|
// select {
|
||||||
|
// case <-worderDone:
|
||||||
|
// closeCh <- struct{}{}
|
||||||
|
// }
|
||||||
|
//}()
|
||||||
|
var worderDone bool
|
||||||
|
wait := func() {
|
||||||
|
if !worderDone {
|
||||||
|
worderDone = true
|
||||||
pool.wg.Wait()
|
pool.wg.Wait()
|
||||||
pool.closeCh <- struct{}{}
|
close(closeCh)
|
||||||
}
|
}
|
||||||
}()
|
}
|
||||||
|
|
||||||
Loop:
|
Loop:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case u, ok := <-pool.worder.C:
|
case u, ok := <-pool.worder.C:
|
||||||
if !ok {
|
if !ok {
|
||||||
|
go wait()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
pool.Statistor.End++
|
pool.Statistor.End++
|
||||||
if int(pool.reqCount) < offset {
|
if pool.reqCount < offset {
|
||||||
pool.reqCount++
|
pool.reqCount++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if pool.Statistor.End > limit {
|
if pool.Statistor.End > limit {
|
||||||
|
go wait()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if u == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pool.wg.Add(1)
|
pool.wg.Add(1)
|
||||||
pool.reqPool.Invoke(newUnit(u, WordSource))
|
pool.reqPool.Invoke(newUnit(u, WordSource))
|
||||||
case source := <-pool.checkCh:
|
case source := <-pool.checkCh:
|
||||||
@ -251,7 +259,7 @@ Loop:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
pool.reqPool.Invoke(unit)
|
pool.reqPool.Invoke(unit)
|
||||||
case <-pool.closeCh:
|
case <-closeCh:
|
||||||
break Loop
|
break Loop
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
break Loop
|
break Loop
|
||||||
@ -260,6 +268,7 @@ Loop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pool.wg.Wait()
|
||||||
for pool.analyzeDone {
|
for pool.analyzeDone {
|
||||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@ func GetSourceName(s int) string {
|
|||||||
return "rule"
|
return "rule"
|
||||||
case 10:
|
case 10:
|
||||||
return "bak"
|
return "bak"
|
||||||
|
case 11:
|
||||||
|
return "common"
|
||||||
default:
|
default:
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user