本文整理匯總了Golang中github.com/docker/libnetwork/bitseq.Handle.Unset方法的典型用法代碼示例。如果您正苦於以下問題:Golang Handle.Unset方法的具體用法?Golang Handle.Unset怎麽用?Golang Handle.Unset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/libnetwork/bitseq.Handle
的用法示例。
在下文中一共展示了Handle.Unset方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Release
// Release allows releasing the address from the specified address space
func (a *Allocator) Release(addrSpace AddressSpace, address net.IP) {
var (
space *bitseq.Handle
sub *net.IPNet
)
if address == nil {
log.Debugf("Requested to remove nil address from address space %s", addrSpace)
return
}
ver := getAddressVersion(address)
if ver == v4 {
address = address.To4()
}
// Find the subnet containing the address
for _, subKey := range a.getSubnetList(addrSpace, ver) {
sub = subKey.canonicalChildSubnet()
if sub.Contains(address) {
a.Lock()
space = a.addresses[subKey]
a.Unlock()
break
}
}
if space == nil {
log.Debugf("Could not find subnet on address space %s containing %s on release", addrSpace, address.String())
return
}
// Retrieve correspondent ordinal in the subnet
hostPart, err := types.GetHostPartIP(address, sub.Mask)
if err != nil {
log.Warnf("Failed to release address %s on address space %s because of internal error: %v", address.String(), addrSpace, err)
return
}
ordinal := ipToUint32(hostPart)
// Release it
if err := space.Unset(ordinal); err != nil {
log.Warnf("Failed to release address %s on address space %s because of internal error: %v", address.String(), addrSpace, err)
}
}