"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "internal/dirlock/dirlock.go" between
nsq-1.2.0.tar.gz and nsq-1.2.1.tar.gz

About: nsq is a realtime distributed and and decentralized messaging platform.

dirlock.go  (nsq-1.2.0):dirlock.go  (nsq-1.2.1)
// +build !windows // +build !windows,!illumos
package dirlock package dirlock
import ( import (
"fmt" "fmt"
"os" "os"
"syscall" "syscall"
) )
type DirLock struct { type DirLock struct {
skipping to change at line 30 skipping to change at line 30
} }
func (l *DirLock) Lock() error { func (l *DirLock) Lock() error {
f, err := os.Open(l.dir) f, err := os.Open(l.dir)
if err != nil { if err != nil {
return err return err
} }
l.f = f l.f = f
err = syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB) err = syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB)
if err != nil { if err != nil {
return fmt.Errorf("cannot flock directory %s - %s", l.dir, err) return fmt.Errorf("cannot flock directory %s - %s (possibly in us e by another instance of nsqd)", l.dir, err)
} }
return nil return nil
} }
func (l *DirLock) Unlock() error { func (l *DirLock) Unlock() error {
defer l.f.Close() defer l.f.Close()
return syscall.Flock(int(l.f.Fd()), syscall.LOCK_UN) return syscall.Flock(int(l.f.Fd()), syscall.LOCK_UN)
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)