// unlockLease unlocks a given lease ID
429965
func (m *ExpirationManager) unlockLease(leaseID string) {
	locksutil.LockForKey(m.restoreLocks, leaseID).Unlock()
}
740116
func (t *MemoryPool) AddLease(newLease leasepool.Lease) error {
	t.poolLock.Lock()
	defer t.poolLock.Unlock()

	if t.pool == nil {
		t.pool = make([]leasepool.Lease, 0)
	}

	for i := range t.pool {
		if t.pool[i].IP.Equal(newLease.IP) {
			//Lease Already Exists In Pool
			return errors.New("Error: Lease IP \"" + newLease.IP.String() + "\" alreay exists in Pool")
		}
	}

	t.pool = append([]leasepool.Lease{newLease}, t.pool...)
	return nil
}
817129
func (l *FileLock) Unlock() error {
	return syscall.Flock(l.fd, syscall.LOCK_UN)
}
717633
func (ld *zkLockDescriptor) Unlock(ctx context.Context) error {
	return ld.zs.Delete(ctx, ld.nodePath, nil)
}
1285023
func (sd *etcdServiceDiscovery) renewLease() error {
	c := make(chan error)
	go func() {
		defer close(c)
		logger.Log.Infof("waiting for etcd lease")
		err := sd.grantLease()
		if err != nil {
			c <- err
			return
		}
		err = sd.bootstrapServer(sd.server)
		c <- err
	}()
	select {
	case err := <-c:
		return err
	case <-time.After(sd.grantLeaseTimeout):
		return constants.ErrEtcdGrantLeaseTimeout
	}
}
676132
func (l *fileLock) Unlock() error {
	defer l.mu.Unlock()
	return syscall.Close(l.fd)
}
745418
func (s *leaseStore) PinLease(key lease.Key, entity string, _ <-chan struct{}) error {
	return errors.NotImplementedf("lease pinning")
}
998785
func checkLease(clusterMap *Map, leaseMap *leases.Map, clusterName string) (*container.Cluster, error) {
	cluster, _ := clusterMap.ClusterByName(clusterName)
	_, isLeased := leaseMap.LeaseByClusterName(clusterName)
	if !isLeased {
		return cluster, nil
	}
	return nil, errUnusedGKEClusterNotFound
}
1019789
func (fm *filesManager) unlockFile(file *file) {
	if !atomic.CompareAndSwapInt32(&file.state, fileInUse, fileOpened) {
		panic(fmt.Errorf("failed to switch state from fileInUse to fileOpened for file %q, state=%v",
			file.name, file.state))
	}
}
565944
func (b *boundManager) leaseKey(leaseName string) lease.Key {
	return lease.Key{
		Namespace: b.namespace,
		ModelUUID: b.modelUUID,
		Lease:     leaseName,
	}
}
1218408
func (s *Server) GetLease(packet dhcp4.Packet) (found bool, lease leasepool.Lease, err error) {
	packetOptions := packet.ParseOptions()

	clientID := getClientID(packetOptions)

	//Requested an IP
	if (len(packetOptions) > 0) &&
		packetOptions[dhcp4.OptionRequestedIPAddress] != nil &&
		!net.IP(packetOptions[dhcp4.OptionRequestedIPAddress]).Equal(net.IP{}) {
		//An IP Has Been Requested Let's Try and Get that One.

		found, lease, err = s.leasePool.GetLease(net.IP(packetOptions[dhcp4.OptionRequestedIPAddress]))
		if err != nil {
			return
		}

		if found {
			//If lease is free, return it to client. If it is not
			//free match against the MAC address and client
			//identifier.
			if lease.Status == leasepool.Free {
				//Lease Is Free you Can Have it.
				return
			}
			if bytes.Equal(lease.MACAddress, packet.CHAddr()) &&
				bytes.Equal(lease.ClientID, clientID) {
				//Lease isn't free but it's yours
				return
			}
		}
	}

	//Ok Even if you requested an IP you can't have it.
	found, lease, err = s.leasePool.GetLeaseForClient(packet.CHAddr(), clientID)
	if found || err != nil {
		return
	}

	//Just get the next free lease if you can.
	found, lease, err = s.leasePool.GetNextFreeLease()
	return
}
79219
func (ks *KeyStore) Unlock(account *Account, passphrase string) error {
	return ks.keystore.TimedUnlock(account.account, passphrase, 0)
}
493084
func NewLeaseCache(conf *LeaseCacheConfig) (*LeaseCache, error) {
	if conf == nil {
		return nil, errors.New("nil configuration provided")
	}

	if conf.Proxier == nil || conf.Logger == nil {
		return nil, fmt.Errorf("missing configuration required params: %v", conf)
	}

	if conf.Client == nil {
		return nil, fmt.Errorf("nil API client")
	}

	db, err := cachememdb.New()
	if err != nil {
		return nil, err
	}

	// Create a base context for the lease cache layer
	baseCtxInfo := cachememdb.NewContextInfo(conf.BaseContext)

	return &LeaseCache{
		client:      conf.Client,
		proxier:     conf.Proxier,
		logger:      conf.Logger,
		db:          db,
		baseCtxInfo: baseCtxInfo,
		l:           &sync.RWMutex{},
		idLocks:     locksutil.CreateLocks(),
	}, nil
}
1035417
func (ld *consulLockDescriptor) Unlock(ctx context.Context) error {
	return ld.s.unlock(ctx, ld.lockPath)
}
1030640
func checkLease(clusterMap *Map, leaseMap *leases.Map, clusterName string) (*containerservice.ContainerService, error) {
	cluster, _ := clusterMap.ClusterByName(clusterName)
	_, isLeased := leaseMap.LeaseByClusterName(clusterName)
	if !isLeased {
		return cluster, nil
	}
	return nil, errUnusedAzureClusterNotFound
}
398913
func (l *Leader) ReleaseLead() error {
	if l.lockPath == "" {
		return ErrNotLocked
	}
	if err := l.c.Delete(l.lockPath, -1); err != nil {
		return xlateError(err)
	}
	l.lockPath = ""
	return nil
}
97578
func (b *backend) Lease(ctx context.Context, s logical.Storage) (*configLease, error) {
	entry, err := s.Get(ctx, "config/lease")
	if err != nil {
		return nil, err
	}
	if entry == nil {
		return nil, nil
	}

	var result configLease
	if err := entry.DecodeJSON(&result); err != nil {
		return nil, err
	}

	return &result, nil
}