diff --git a/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php b/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php index b138a2ef7d..9babe3ebb1 100644 --- a/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php +++ b/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php @@ -21,22 +21,30 @@ final class DiffusionGitReceivePackSSHWorkflow extends DiffusionGitSSHWorkflow { 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 @@ final class DiffusionGitReceivePackSSHWorkflow extends DiffusionGitSSHWorkflow { $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 index 18e45359ce..ee7f6b6bb6 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -2410,9 +2410,6 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO 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 index 00e74a3d61..1b1150f8cd 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php +++ b/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php @@ -82,7 +82,7 @@ final class PhabricatorRepositoryWorkingCopyVersion $table, $repository_phid, $device_phid, - 1, + 0, 1); }