From bc86a6a671f4f7bd53d7ffbf5159e9d741849b0a Mon Sep 17 00:00:00 2001
From: Greg DiCristofaro <gregd@basistech.com>
Date: Tue, 14 Jun 2022 16:19:21 -0400
Subject: [PATCH] wait timeout

---
 .../CommandLineIngestManager.java                | 16 +++++++++-------
 .../autoingest/AutoIngestManager.java            |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java
index 6823e8f9f2..650baf9053 100755
--- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java
+++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java
@@ -509,15 +509,17 @@ private void analyze(AutoIngestDataSource dataSource, String ingestProfileName)
                     if (settingsWarnings.isEmpty()) {
                         IngestJobStartResult ingestJobStartResult = IngestManager.getInstance().beginIngestJob(dataSource.getContent(), ingestJobSettings);
                         IngestJob ingestJob = ingestJobStartResult.getJob();
-                        if (null != ingestJob) {
+                            if (null != ingestJob) {
                             /*
-                             * Block until notified by the ingest job event
-                             * listener or until interrupted because auto ingest
-                             * is shutting down.
+                             * Block until notified by the ingest job event listener
+                             * or until interrupted because auto ingest is shutting
+                             * down. For very small jobs, it is possible that ingest has
+                             * completed by the time we get here, so check periodically
+                             * in case the event was missed.
                              */
-                            do {
-                                ingestLock.wait();
-                            } while (IngestManager.getInstance().isIngestRunning());
+                            while (IngestManager.getInstance().isIngestRunning()) {
+                                ingestLock.wait(60000);  // Check every minute
+                            }
 
                             LOGGER.log(Level.INFO, "Finished ingest modules analysis for {0} ", dataSource.getPath());
                             IngestJob.ProgressSnapshot jobSnapshot = ingestJob.getSnapshot();
diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java
index d4f789a861..787be9cc30 100644
--- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java
+++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java
@@ -2819,7 +2819,7 @@ private void analyze(AutoIngestDataSource dataSource) throws AnalysisStartupExce
                          * in case the event was missed.
                          */
                         while (IngestManager.getInstance().isIngestRunning()) {
-                            ingestLock.wait(300000);  // Check every five minutes
+                            ingestLock.wait(60000);  // Check every minute
                         }
                         IngestJob.ProgressSnapshot jobSnapshot = ingestJob.getSnapshot();
                         IngestJob.ProgressSnapshot.DataSourceProcessingSnapshot snapshot = jobSnapshot.getDataSourceProcessingSnapshot();
-- 
GitLab