Unlock releases the advisory lock and closes the sentinel file descriptor.
()
| 130 | |
| 131 | // Unlock releases the advisory lock and closes the sentinel file descriptor. |
| 132 | func (l *FileLock) Unlock() error { |
| 133 | l.mu.Lock() |
| 134 | defer l.mu.Unlock() |
| 135 | |
| 136 | if l.file == nil { |
| 137 | return nil |
| 138 | } |
| 139 | |
| 140 | f := l.file |
| 141 | l.file = nil |
| 142 | |
| 143 | unlockErr := unlockFile(f) |
| 144 | closeErr := f.Close() |
| 145 | l.processLock.Unlock() |
| 146 | if unlockErr != nil { |
| 147 | return fmt.Errorf("unlocking memory lock file %q: %w", l.path, unlockErr) |
| 148 | } |
| 149 | if closeErr != nil { |
| 150 | return fmt.Errorf("closing memory lock file %q: %w", l.path, closeErr) |
| 151 | } |
| 152 | return nil |
| 153 | } |