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()
|
a.grab()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *agent) grab() {
|
func (a *agent) grab() bool {
|
||||||
|
if a.worker.closed != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
outpack := getOutPack()
|
outpack := getOutPack()
|
||||||
outpack.dataType = dtGrabJobUniq
|
outpack.dataType = dtGrabJobUniq
|
||||||
a.write(outpack)
|
a.write(outpack)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *agent) PreSleep() {
|
func (a *agent) PreSleep() {
|
||||||
@ -169,9 +173,10 @@ func (a *agent) reconnect() error {
|
|||||||
bufio.NewWriter(a.conn))
|
bufio.NewWriter(a.conn))
|
||||||
|
|
||||||
a.worker.reRegisterFuncsForAgent(a)
|
a.worker.reRegisterFuncsForAgent(a)
|
||||||
a.grab()
|
if a.grab() {
|
||||||
|
go a.work()
|
||||||
|
}
|
||||||
|
|
||||||
go a.work()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ func (worker *Worker) exec(inpack *inPack) (err error) {
|
|||||||
}
|
}
|
||||||
outpack.handle = inpack.handle
|
outpack.handle = inpack.handle
|
||||||
outpack.data = r.data
|
outpack.data = r.data
|
||||||
err = inpack.a.Write(outpack)
|
_ = inpack.a.Write(outpack)
|
||||||
if worker.leftJobs != nil {
|
if worker.leftJobs != nil {
|
||||||
worker.leftJobs <- struct{}{}
|
worker.leftJobs <- struct{}{}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user