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) { for (Recording rec : toStop) {
Optional.ofNullable(rec.getDownload()).ifPresent(Download::stop); Optional.ofNullable(rec.getDownload()).ifPresent(Download::stop);
} }
} finally {
recordingsLock.unlock();
}
// wait for post-processing to finish // wait for post-processing to finish
LOG.info("Waiting for downloads to finish"); LOG.info("Waiting for downloads to finish");
while (!recordingProcesses.isEmpty()) { for (int i = 0; i < 60; i++) {
if (!recordingProcesses.isEmpty()) {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
LOG.error("Error while waiting for downloads to finish", e); LOG.error("Error while waiting for downloads to finish", e);
} }
} }
} finally {
recordingsLock.unlock();
} }
// shutdown threadpools // shutdown threadpools

View File

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

View File

@ -374,7 +374,8 @@ public class MergedHlsDownload extends AbstractHlsDownload {
} }
@Override @Override
public void stop() { public synchronized void stop() {
if (running) {
internalStop(); internalStop();
try { try {
synchronized (downloadFinished) { synchronized (downloadFinished) {
@ -386,6 +387,7 @@ public class MergedHlsDownload extends AbstractHlsDownload {
} }
LOG.debug("Download stopped"); LOG.debug("Download stopped");
} }
}
@Override @Override
void internalStop() { void internalStop() {