| 86 | } |
| 87 | |
| 88 | func (n *NodeLock) lock() (err error) { |
| 89 | if lockDebug { |
| 90 | fmt.Printf("start NodeLock.lock gid=%d node=%s\n", getGID(), n.Id) |
| 91 | } |
| 92 | select { |
| 93 | case <-n.writeLock: // Grab the ticket - here is where we wait |
| 94 | case <-time.After(time.Minute * 30): |
| 95 | err = fmt.Errorf("Timeout!! Waited 30 mins on lock for node %s", n.Id) |
| 96 | return |
| 97 | } |
| 98 | n.IsLocked = true |
| 99 | n.Updated = time.Now() |
| 100 | if lockDebug { |
| 101 | fmt.Printf("end NodeLock.lock gid=%d node=%s\n", getGID(), n.Id) |
| 102 | } |
| 103 | return |
| 104 | } |
| 105 | |
| 106 | func (n *NodeLock) unlock() { |
| 107 | if lockDebug { |