diff --git a/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php b/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php --- a/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php +++ b/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php @@ -21,22 +21,30 @@ if ($this->shouldProxy()) { $command = $this->getProxyCommand(); - $is_proxy = true; + $did_synchronize = false; } else { $command = csprintf('git-receive-pack %s', $repository->getLocalPath()); - $is_proxy = false; + $did_synchronize = true; $repository->synchronizeWorkingCopyBeforeWrite(); } - $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); - $future = id(new ExecFuture('%C', $command)) - ->setEnv($this->getEnvironment()); + $caught = null; + try { + $err = $this->executeRepositoryCommand($command); + } catch (Exception $ex) { + $caught = $ex; + } - $err = $this->newPassthruCommand() - ->setIOChannel($this->getIOChannel()) - ->setCommandChannelFromExecFuture($future) - ->execute(); + // We've committed the write (or rejected it), so we can release the lock + // without waiting for the client to receive the acknowledgement. + if ($did_synchronize) { + $repository->synchronizeWorkingCopyAfterWrite(); + } + + if ($caught) { + throw $caught; + } if (!$err) { $repository->writeStatusMessage( @@ -45,11 +53,20 @@ $this->waitForGitClient(); } - if (!$is_proxy) { - $repository->synchronizeWorkingCopyAfterWrite(); - } - return $err; } + private function executeRepositoryCommand($command) { + $repository = $this->getRepository(); + $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); + + $future = id(new ExecFuture('%C', $command)) + ->setEnv($this->getEnvironment()); + + return $this->newPassthruCommand() + ->setIOChannel($this->getIOChannel()) + ->setCommandChannelFromExecFuture($future) + ->execute(); + } + } diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -2410,9 +2410,6 @@ private function shouldEnableSynchronization() { - // TODO: This mostly works, but isn't stable enough for production yet. - return false; - $device = AlmanacKeys::getLiveDevice(); if (!$device) { return false; diff --git a/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php b/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php --- a/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php +++ b/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php @@ -82,7 +82,7 @@ $table, $repository_phid, $device_phid, - 1, + 0, 1); }