Improved deadlock handling. We will now throw a warning after 1 minute and abort after 5 minutes of inactivity. This may still be too short for FFVideoSource() to finish indexing on extremely large files. Though in this case the user should use 'ffmsindex' to create the index beforehand.

This commit is contained in:
LoRd_MuldeR 2012-02-11 16:10:21 +01:00
parent 1d5af73ac7
commit ac5d2c4f89
3 changed files with 32 additions and 10 deletions

View File

@ -345,11 +345,11 @@ bool EncodeThread::runEncodingPass(bool x264_x64, bool avs2yuv_x64, bool usePipe
waitCounter = 0;
continue;
}
if(!processEncode.waitForReadyRead(2500))
if(!processEncode.waitForReadyRead(m_processTimeoutInterval))
{
if(processEncode.state() == QProcess::Running)
{
if(waitCounter++ > m_processTimeoutCounter)
if(waitCounter++ > m_processTimeoutMaxCounter)
{
processEncode.kill();
qWarning("x264 process timed out <-- killing!");
@ -357,6 +357,11 @@ bool EncodeThread::runEncodingPass(bool x264_x64, bool avs2yuv_x64, bool usePipe
bTimeout = true;
break;
}
else if(waitCounter == m_processTimeoutWarning)
{
unsigned int timeOut = (waitCounter * m_processTimeoutInterval) / 1000U;
log(tr("Warning: x264 did not respond for %1 seconds, potential deadlock...").arg(QString::number(timeOut)));
}
continue;
}
}
@ -764,6 +769,8 @@ bool EncodeThread::checkProperties(bool x64, unsigned int &frames)
unsigned int fSizeW = 0;
unsigned int fSizeH = 0;
unsigned int waitCounter = 0;
while(process.state() != QProcess::NotRunning)
{
if(m_abort)
@ -772,17 +779,30 @@ bool EncodeThread::checkProperties(bool x64, unsigned int &frames)
bAborted = true;
break;
}
if(!process.waitForReadyRead())
if(!process.waitForReadyRead(m_processTimeoutInterval))
{
if(process.state() == QProcess::Running)
{
if(waitCounter++ > m_processTimeoutMaxCounter)
{
process.kill();
qWarning("Avs2YUV process timed out <-- killing!");
log("\nPROCESS TIMEOUT !!!");
log("\nAvisynth has encountered a deadlock or your script takes EXTREMELY long to initialize!");
bTimeout = true;
break;
}
else if(waitCounter == m_processTimeoutWarning)
{
unsigned int timeOut = (waitCounter * m_processTimeoutInterval) / 1000U;
log(tr("Warning: Avisynth did not respond for %1 seconds, potential deadlock...").arg(QString::number(timeOut)));
}
}
continue;
}
waitCounter = 0;
while(process.bytesAvailable() > 0)
{
QList<QByteArray> lines = process.readLine().split('\r');

View File

@ -79,7 +79,9 @@ public:
protected:
static QMutex m_mutex_startProcess;
static const int m_processTimeoutCounter = 24;
static const unsigned int m_processTimeoutInterval = 2500;
static const unsigned int m_processTimeoutMaxCounter = 120;
static const unsigned int m_processTimeoutWarning = 24;
//Constants
const QUuid m_jobId;

View File

@ -22,7 +22,7 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 0
#define VER_X264_PATCH 1
#define VER_X264_BUILD 119
#define VER_X264_BUILD 126
#define VER_X264_MINIMUM_REV 2146
#define VER_X264_CURRENT_API 120