diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-05-07 19:50:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 19:50:54 +0200 |
commit | 7b67c9601e1eab6c881ac44503c285c71b0a4a3a (patch) | |
tree | cf0802d1dee6beefd68e20b2a8345c9edeaec80f /libpod/lock/shm/shm_lock.go | |
parent | 3b5ac1818f09514039fdfec20aa874ae68e6ab7c (diff) | |
parent | f881e32f12c9a30d903b15d8d51729b23928cfa3 (diff) | |
download | podman-7b67c9601e1eab6c881ac44503c285c71b0a4a3a.tar.gz podman-7b67c9601e1eab6c881ac44503c285c71b0a4a3a.tar.bz2 podman-7b67c9601e1eab6c881ac44503c285c71b0a4a3a.zip |
Merge pull request #3073 from mheon/force_lock_realloc
When refreshing after a reboot, force lock allocation
Diffstat (limited to 'libpod/lock/shm/shm_lock.go')
-rw-r--r-- | libpod/lock/shm/shm_lock.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libpod/lock/shm/shm_lock.go b/libpod/lock/shm/shm_lock.go index e70ea8743..c21e9a221 100644 --- a/libpod/lock/shm/shm_lock.go +++ b/libpod/lock/shm/shm_lock.go @@ -134,6 +134,23 @@ func (locks *SHMLocks) AllocateSemaphore() (uint32, error) { return uint32(retCode), nil } +// AllocateGivenSemaphore allocates the given semaphore from the shared-memory +// segment for use by a container or pod. +// If the semaphore is already in use or the index is invalid an error will be +// returned. +func (locks *SHMLocks) AllocateGivenSemaphore(sem uint32) error { + if !locks.valid { + return errors.Wrapf(syscall.EINVAL, "locks have already been closed") + } + + retCode := C.allocate_given_semaphore(locks.lockStruct, C.uint32_t(sem)) + if retCode < 0 { + return syscall.Errno(-1 * retCode) + } + + return nil +} + // DeallocateSemaphore frees a semaphore in a shared-memory segment so it can be // reallocated to another container or pod. // The given semaphore must be already allocated, or an error will be returned. |