fix(ida): share concurrent session cleanup (#950)

This commit is contained in:
morluto
2026-10-07 19:58:43 +08:00
committed by GitHub
parent 118d43e787
commit f14b6a8430
2 changed files with 41 additions and 0 deletions
+11
View File
@@ -95,6 +95,7 @@ export class IdaSessionClient implements AnalysisClient {
#startup: Promise<void> | undefined;
#closed = false;
#closing = false;
#closePromise: Promise<Result<null, AnalysisError>> | undefined;
#workspace: IdaWorkspace | undefined;
#database: string | undefined;
#openAttempted = false;
@@ -385,6 +386,16 @@ export class IdaSessionClient implements AnalysisClient {
}
async closeWithOutcome(): Promise<Result<null, AnalysisError>> {
if (this.#closePromise !== undefined) return this.#closePromise;
const closing = this.#closeOnce();
const shared = closing.finally(() => {
if (this.#closePromise === shared) this.#closePromise = undefined;
});
this.#closePromise = shared;
return shared;
}
async #closeOnce(): Promise<Result<null, AnalysisError>> {
this.#closing = true;
await this.#tail;
if (this.#closed) return ok(null);