bugfix:单机单进程模式下锁没正确释放

pull/58/head
daxing 2018-02-20 18:36:01 +08:00
parent 26515e84c9
commit 8794fd12b9
1 changed files with 6 additions and 0 deletions

6
job.go
View File

@ -91,6 +91,7 @@ type locker struct {
kind int
ttl int64
lID client.LeaseID
lKey string
timer *time.Timer
done chan struct{}
}
@ -123,6 +124,10 @@ func (l *locker) unlock() {
if _, err := DefalutClient.KeepAliveOnce(l.lID); err != nil {
log.Warnf("unlock keep alive err: %s", err.Error())
}
err := DefalutClient.DelLock(l.lKey)
if err != nil {
log.Warnf("unlock[%s] err: %s", l.lKey, err.Error())
}
}
type Cmd struct {
@ -265,6 +270,7 @@ func (c *Cmd) lock() *locker {
}
lk.lID = resp.ID
lk.lKey = c.Job.ID
if lk.kind == KindAlone {
go lk.keepAlive()
}