Skip to content

Commit

Permalink
Fix Flock PID locking
Browse files Browse the repository at this point in the history
Remove race condition and fix warning log.
  • Loading branch information
tempusfrangit committed Dec 19, 2023
1 parent 90e77e4 commit 296c401
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/cli/pid.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (p *PIDFile) Acquire() error {
if err != nil {
logger.Warn().
Err(err).
Str("message", "Another pget process may be running, use 'pget multifile' to download multiple files in parallel").
Str("warn_message", "Another pget process may be running, use 'pget multifile' to download multiple files in parallel").
Msg("Waiting on Lock")
logger.Debug().Str("blocking_lock_acquire", "true").Msg("Waiting on Lock")
err = syscall.Flock(p.fd, syscall.LOCK_EX)
Expand All @@ -49,7 +49,6 @@ func (p *PIDFile) Release() error {
funcs := []func() error{
func() error { return syscall.Flock(p.fd, syscall.LOCK_UN) },
p.file.Close,
func() error { return os.Remove(p.file.Name()) },
}
return p.executeFuncs(funcs)
}
Expand Down

0 comments on commit 296c401

Please sign in to comment.