server/lib/sync-protocol-handler.js
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();
    });
  }
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();
    });
  }
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 ( ) ; } ) ; }
If we're still holding a valid lock, release it first.
If we re still holding a valid lock release it first .