forked from yuxh/gearman-go
调用Close后不再向JobServer获取任务
This commit is contained in:
parent
97187ecbf9
commit
abd6ce9be3
@ -143,10 +143,14 @@ func (a *agent) Grab() {
|
||||
a.grab()
|
||||
}
|
||||
|
||||
func (a *agent) grab() {
|
||||
func (a *agent) grab() bool {
|
||||
if a.worker.closed != nil {
|
||||
return false
|
||||
}
|
||||
outpack := getOutPack()
|
||||
outpack.dataType = dtGrabJobUniq
|
||||
a.write(outpack)
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *agent) PreSleep() {
|
||||
@ -169,9 +173,10 @@ func (a *agent) reconnect() error {
|
||||
bufio.NewWriter(a.conn))
|
||||
|
||||
a.worker.reRegisterFuncsForAgent(a)
|
||||
a.grab()
|
||||
if a.grab() {
|
||||
go a.work()
|
||||
}
|
||||
|
||||
go a.work()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ func (worker *Worker) exec(inpack *inPack) (err error) {
|
||||
}
|
||||
outpack.handle = inpack.handle
|
||||
outpack.data = r.data
|
||||
err = inpack.a.Write(outpack)
|
||||
_ = inpack.a.Write(outpack)
|
||||
if worker.leftJobs != nil {
|
||||
worker.leftJobs <- struct{}{}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user