forked from j62/ctbrec
1
0
Fork 0

Hopefully fixed some deadlocks

This commit is contained in:
0xboobface 2019-06-03 21:16:35 +02:00
parent b136fce0db
commit 645f0b8231
3 changed files with 27 additions and 21 deletions

View File

@ -411,18 +411,20 @@ public class NextGenLocalRecorder implements Recorder {
for (Recording rec : toStop) {
Optional.ofNullable(rec.getDownload()).ifPresent(Download::stop);
}
} finally {
recordingsLock.unlock();
}
// wait for post-processing to finish
LOG.info("Waiting for downloads to finish");
while (!recordingProcesses.isEmpty()) {
// wait for post-processing to finish
LOG.info("Waiting for downloads to finish");
for (int i = 0; i < 60; i++) {
if (!recordingProcesses.isEmpty()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOG.error("Error while waiting for downloads to finish", e);
}
}
} finally {
recordingsLock.unlock();
}
// shutdown threadpools

View File

@ -237,14 +237,16 @@ public class HlsDownload extends AbstractHlsDownload {
}
@Override
public void stop() {
internalStop();
try {
synchronized (downloadFinished) {
downloadFinished.wait();
public synchronized void stop() {
if (running) {
internalStop();
try {
synchronized (downloadFinished) {
downloadFinished.wait();
}
} catch (InterruptedException e) {
LOG.error("Couldn't wait for download to finish", e);
}
} catch (InterruptedException e) {
LOG.error("Couldn't wait for download to finish", e);
}
}

View File

@ -374,17 +374,19 @@ public class MergedHlsDownload extends AbstractHlsDownload {
}
@Override
public void stop() {
internalStop();
try {
synchronized (downloadFinished) {
LOG.debug("Waiting for finished notify {}", model);
downloadFinished.wait();
public synchronized void stop() {
if (running) {
internalStop();
try {
synchronized (downloadFinished) {
LOG.debug("Waiting for finished notify {}", model);
downloadFinished.wait();
}
} catch (InterruptedException e) {
LOG.error("Couldn't wait for download to finish", e);
}
} catch (InterruptedException e) {
LOG.error("Couldn't wait for download to finish", e);
LOG.debug("Download stopped");
}
LOG.debug("Download stopped");
}
@Override