If we're still holding a valid lock, release it first.
187323
function maybeReleaseLock() {
    var lock = self.client.lock;

    function done(err) {
      log.debug({client: self.client}, 'Closed client sync handler');
      self.client.lock = null;
      self.client = null;
      callback(err);
    }

    // No lock
    if(!lock) {
      return done();
    }
    // Lock reference, but it's already unlocked
    if(lock.unlocked) {
      return done();
    }
    // Holding lock, release it
    lock.release(function(err) {
      if(err) {
        log.error({err: err, client: self.client}, 'Error releasing sync lock');
        return done(err);
      }
      done();
    });
  }
367964
private void waitForCoordinator()
   {
      LOG.info("Waiting to be released by the coordinator");
      try
      {
         lock.await();
      }
      catch (InterruptedException e)
      {
         Thread.currentThread().interrupt();
      }
   }
691878
def _release_lock(self):
        """"""
        if not self._has_lock():
            return

        # if someone removed our file beforhand, lets just flag this issue
        # instead of failing, to make it more usable.
        lfp = self._lock_file_path()
        try:
            # on bloody windows, the file needs write permissions to be removable.
            # Why ...
            if os.name == 'nt':
                os.chmod(lfp, 0777)
            # END handle win32
            os.remove(lfp)
        except OSError:
            pass
        self._owns_lock = False
353227
public void release(int capacity) {
        if (capacity < 0) {
            throw new IllegalArgumentException("capacity to release cannot be negative");
        }

        // in the common 'good' case where we have our full capacity available we can
        // short circuit going any further and avoid unnecessary locking.
        if (availableCapacity >= 0 && availableCapacity != maxCapacity) {
            synchronized (lock) {
                availableCapacity = Math.min((availableCapacity + capacity), maxCapacity);
            }
        }
    }
1256036
def release(self):
        
        unlocked = self.database.run_script(
            'lock_release',
            keys=[self.key, self.event],
            args=[self._lock_id])
        return unlocked != 0
1075263
public final void release() {
		synchronized (this.LOCK) {
			if ((this.owner != null)
					&& (this.owner.get() == Thread.currentThread())) {
				this.acquire--;

				if (this.acquire == 0) {
					this.owner = null;
					this.LOCK.notify();
				}

				return;
			}

			if ((this.owner != null) && (this.owner.get() == null)) {
				this.owner = null;
				this.acquire = 0;
				this.LOCK.notify();
			}

			throw new IllegalMonitorStateException(Thread.currentThread()
					.getName()
					+ " is not the owner of the lock. "
					+ ((this.owner != null) ? ((Thread) this.owner.get())
							.getName() : "nobody") + " is the owner.");
		}
	}
300087
public final void release(TotalOrderRemoteTransactionState state) {
      TotalOrderLatch synchronizedBlock = state.getTransactionSynchronizedBlock();
      if (synchronizedBlock == null) {
         //already released!
         return;
      }
      Collection<Object> lockedKeys = state.getLockedKeys();
      synchronizedBlock.unBlock();
         for (Object key : lockedKeys) {
            keysLocked.remove(key, synchronizedBlock);
         }
      if (trace) {
         log.tracef("Release %s and locked keys %s. Checking pending tasks!", synchronizedBlock, lockedKeys);
      }
      state.reset();
   }
734624
def release_readlock(lockdir_name):
    
    # Make sure the lock still exists before deleting it
    if os.path.exists(lockdir_name) and os.path.isdir(lockdir_name):
        os.rmdir(lockdir_name)
1014751
def release_locks(self):
        
        if self._remotelib:
            self._remotelib.run_keyword('release_locks',
                                        [self._my_id], {})
        else:
            _PabotLib.release_locks(self, self._my_id)
964960
def release(self):
        
        if self._lock_fd is not None:
            os.close(self._lock_fd)
            try:
                os.remove(self._lock_filename)
            except OSError:
                # Hmm, someone deleted our lock while we had it locked?
                # Nothing we can do, so just continue
                pass
595545
def release(self):
        
        if self._local.locked:
            while self._queue:
                future = self._queue.popleft()
                if not future.done():
                    return future.set_result(None)
            self._local.locked = None
        else:
            raise RuntimeError('release unlocked lock')
445965
public function release()
    {
        $this->redis->eval(LuaScripts::releaseLock(), 1, $this->name, $this->owner);
    }
1145156
def valid_lock(self):
        

        lock_pid = self.get_lock_pid()

        # If we're unable to get lock_pid
        if lock_pid is None:
            return False

        # this is our process
        if self._pid == lock_pid:
            return True

        # it is/was another process
        # see if it is running
        try:
            os.kill(lock_pid, 0)
        except OSError:
            self.release()
            return False

        # it is running
        return True
1304553
def release(self):
        
        
        if self.is_locked_by_me():
            os.remove(self.lock_filename)
            logger.debug('The lock {} is released by me (pid: {}).'.format(self.lock_filename, self.pid))
        if self.fd:
            os.close(self.fd)
            self.fd = None
469735
public function release() {
        if (!$this->releaser) {
            return;
        }

        // Invoke the releaser function given to us by the synchronization source
        // to release the lock.
        $releaser = $this->releaser;
        $this->releaser = null;
        ($releaser)($this);
    }
1008172
def _release(self):
        """"""
        if self._in_use is None:
            # The holder is not checked out.
            return

        if not self._in_use.done():
            self._in_use.set_result(None)
        self._in_use = None

        # Deinitialize the connection proxy.  All subsequent
        # operations on it will fail.
        if self._proxy is not None:
            self._proxy._detach()
            self._proxy = None

        # Put ourselves back to the pool queue.
        self._pool._queue.put_nowait(self)
1006522
public synchronized void lockExclusive()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "lockExclusive", this);

        boolean interrupted = false;

        // If another thread is attempting to lock exclusive,
        // wait for it to finish first.
        while (!tryLockExclusive())
        {
            try
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting to get exclusive lock");
                wait(1000);
            }
            catch (InterruptedException e)
            {
                // No FFDC code needed
                interrupted = true;
            }
        }

            // Wait for existing locks to be released
        while (iLockCount > 0)
        {
            try
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting for lock count to reach 0 " + iLockCount);
                wait(1000);
            }
            catch (InterruptedException e)
            {
                // No FFDC code needed
                interrupted = true;
            }
        }

        if (interrupted)
        {
            Thread.currentThread().interrupt();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "lockExclusive");
    }