forked from j62/ctbrec
Hopefully fixed some deadlocks
This commit is contained in:
parent
b136fce0db
commit
645f0b8231
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue