correctly support disabling caps with CAP REQ, fixes #337

This commit is contained in:
Shivaram Lingamneni 2019-02-02 20:00:23 -05:00
parent 6667585605
commit f48af3ee44
5 changed files with 55 additions and 9 deletions

View file

@ -89,3 +89,19 @@ func BitsetCopy(set []uint64, other []uint64) {
atomic.StoreUint64(&set[i], data)
}
}
// BitsetSubtract modifies `set` to subtract the contents of `other`.
// Similar caveats about race conditions as with `BitsetUnion` apply.
func BitsetSubtract(set []uint64, other []uint64) {
for i := 0; i < len(set); i++ {
for {
ourAddr := &set[i]
ourBlock := atomic.LoadUint64(ourAddr)
otherBlock := atomic.LoadUint64(&other[i])
newBlock := ourBlock & (^otherBlock)
if atomic.CompareAndSwapUint64(ourAddr, ourBlock, newBlock) {
break
}
}
}
}