From d7b46e0527cd7b52845f37cffc57cbae4ba0b945 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 14 Mar 2020 02:01:28 +0200 Subject: vscode-postrefactor: enforcing more reentrancy --- editors/code/src/installation/extension.ts | 2 +- editors/code/src/installation/server.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/installation/extension.ts b/editors/code/src/installation/extension.ts index 2022d090d..f6dd20d82 100644 --- a/editors/code/src/installation/extension.ts +++ b/editors/code/src/installation/extension.ts @@ -97,7 +97,7 @@ async function askToDownloadProperExtensionVersion(config: Config, reason = "") * * ACHTUNG!: this function has a crazy amount of state transitions, handling errors during * each of them would result in a ton of code (especially accounting for cross-process - * shared mutable `globalState` access). Enforcing reentrancy for this is best-effort. + * shared mutable `globalState` access). Enforcing no reentrancy for this is best-effort. */ const tryDownloadNightlyExtension = notReentrant(async function tryDownloadNightlyExtension( config: Config, diff --git a/editors/code/src/installation/server.ts b/editors/code/src/installation/server.ts index 345f30d47..f35958474 100644 --- a/editors/code/src/installation/server.ts +++ b/editors/code/src/installation/server.ts @@ -5,7 +5,7 @@ import { spawnSync } from "child_process"; import { ArtifactSource } from "./interfaces"; import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info"; import { downloadArtifactWithProgressUi } from "./downloads"; -import { log, assert } from "../util"; +import { log, assert, notReentrant } from "../util"; import { Config, NIGHTLY_TAG } from "../config"; export async function ensureServerBinary(config: Config): Promise { @@ -82,7 +82,10 @@ function shouldDownloadServer( return installed.date.getTime() !== required.date.getTime(); } -async function downloadServer( +/** + * Enforcing no reentrancy for this is best-effort. + */ +const downloadServer = notReentrant(async function downloadServer( source: ArtifactSource.GithubRelease, config: Config, ): Promise { @@ -112,7 +115,7 @@ async function downloadServer( ); return binaryPath; -} +}); function isBinaryAvailable(binaryPath: string): boolean { const res = spawnSync(binaryPath, ["--version"]); -- cgit v1.2.3