From 8a9809969e7326b15df3b4d5b9ac8b55928d1ff8 Mon Sep 17 00:00:00 2001 From: DecFox <33030671+DecFox@users.noreply.github.com> Date: Fri, 29 Nov 2024 04:17:06 -0500 Subject: [PATCH] fix(engine): expose session close (#852) Fixes https://github.com/ooni/probe/issues/2810 ## Proposed Changes - Exposes the `close` function for the engine session - Invokes the `close` function while downloading urls for webconnectivity to ensure the running psiphon tunnel (and engine session) is closed before the experiment run - Changes in engine api surface: https://github.com/ooni/probe-cli/pull/1657 --- .../org/openobservatory/ooniprobe/test/TestAsyncTask.java | 3 +++ .../src/main/java/org/openobservatory/engine/OONISession.java | 3 +++ .../src/main/java/org/openobservatory/engine/PESession.java | 4 ++++ gradle/libs.versions.toml | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/openobservatory/ooniprobe/test/TestAsyncTask.java b/app/src/main/java/org/openobservatory/ooniprobe/test/TestAsyncTask.java index 9613431d2..101a31090 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/test/TestAsyncTask.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/test/TestAsyncTask.java @@ -197,6 +197,9 @@ private void downloadURLs() { currentTest.setMax_runtime(app.getPreferenceManager().getMaxRuntime()); } publishProgress(URL); + + // we close the session to ensure that we have no running circumvention tunnels + session.close(); } catch (Exception e) { e.printStackTrace(); ThirdPartyServices.logException(e); diff --git a/engine/src/main/java/org/openobservatory/engine/OONISession.java b/engine/src/main/java/org/openobservatory/engine/OONISession.java index 2d4ac84fd..69ed92349 100644 --- a/engine/src/main/java/org/openobservatory/engine/OONISession.java +++ b/engine/src/main/java/org/openobservatory/engine/OONISession.java @@ -38,4 +38,7 @@ public interface OONISession { OONIRunDescriptor getLatestOONIRunLink(OONIContext ctx, String probeServicesURL, long id) throws Exception; OONIRunRevisions getOONIRunLinkRevisions(@Nullable OONIContext ooniContext, @NotNull String probeServicesURL, long runId) throws Exception ; + + /** close closes the session along with any running circumvention tunnels */ + void close() throws Exception; } diff --git a/engine/src/main/java/org/openobservatory/engine/PESession.java b/engine/src/main/java/org/openobservatory/engine/PESession.java index 54b6391ee..0917a8a88 100644 --- a/engine/src/main/java/org/openobservatory/engine/PESession.java +++ b/engine/src/main/java/org/openobservatory/engine/PESession.java @@ -58,4 +58,8 @@ public OONIRunRevisions getOONIRunLinkRevisions(OONIContext ooniContext, @NotNul return revisions; } + + public void close() throws Exception { + session.close(); + } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 16777bd3e..616b8c720 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -41,7 +41,7 @@ markwon = "4.6.2" shapeofview = "1.4.7" targetSdk = "35" minSdk = "21" -oonimkall = "2024.08.08-091959" +oonimkall = "2024.11.26-053000" junit = "4.13.2" dbflow = "4.2.4"