Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
difs,interfaces/mount: add support for locking namespaces #3311
Conversation
zyga
added some commits
Apr 24, 2017
| + | ||
| +// Close closes the lock, unlocking it automatically if needed. | ||
| +func (l *NSLock) Close() error { | ||
| + return l.file.Close() |
morphis
May 15, 2017
Contributor
Worth to check if the file is really open and return an error if it is not? If l.file is nil then this will result in a SEGV.
zyga
May 15, 2017
Contributor
l.file can never be nil because only OpenFile can create an instance of l and it checks for errors already.
morphis
May 15, 2017
Contributor
Very much depends on the OpenFile implementation. Feel better when we check l.file as well. But fine if you don't want that. Didn't blocked because of this.
zyga
May 15, 2017
Contributor
I didn't do it because we don't have a habit of checking object fields for being nil unless they can reasonably be nil as a normal case.
| + | ||
| +// Lock acquires an exclusive lock on the mount namespace. | ||
| +func (l *NSLock) Lock() error { | ||
| + return syscall.Flock(int(l.file.Fd()), syscall.LOCK_EX) |
| + | ||
| +// Unlock releases an acquired lock. | ||
| +func (l *NSLock) Unlock() error { | ||
| + return syscall.Flock(int(l.file.Fd()), syscall.LOCK_UN) |
zyga
merged commit 3348589
into
snapcore:master
May 15, 2017
7 checks passed
artful-amd64
autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr
The Travis CI build passed
Details
xenial-amd64
autopkgtest finished (success)
Details
xenial-i386
autopkgtest finished (success)
Details
xenial-ppc64el
autopkgtest finished (success)
Details
yakkety-amd64
autopkgtest finished (success)
Details
zesty-amd64
autopkgtest finished (success)
Details
zyga
deleted the
zyga:feature/update-ns/locking
branch
May 15, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
zyga commentedMay 12, 2017
This patch adds helpers for working with locks that are also used by
snap-confine. They are used by the update-ns feature.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com