Ejemplo n.º 1
0
void
AppManagerPrivate::initBreakpad(const QString& breakpadPipePath,
                                const QString& breakpadComPipePath,
                                int breakpad_client_fd)
{
    assert(!breakpadHandler);
    createBreakpadHandler(breakpadPipePath, breakpad_client_fd);

    /*
       We check periodically that the crash reporter process is still alive. If the user killed it somehow, then we want
       the Natron process to terminate
     */
    breakpadAliveThread = boost::make_shared<ExistenceCheckerThread>(QString::fromUtf8(NATRON_NATRON_TO_BREAKPAD_EXISTENCE_CHECK),
                                                                     QString::fromUtf8(NATRON_NATRON_TO_BREAKPAD_EXISTENCE_CHECK_ACK),
                                                                     breakpadComPipePath);
    QObject::connect( breakpadAliveThread.get(), SIGNAL(otherProcessUnreachable()), appPTR, SLOT(onCrashReporterNoLongerResponding()) );
    breakpadAliveThread->start();
}
Ejemplo n.º 2
0
void
ExistenceCheckerThread::run()
{
    _imp->socket.reset( new QLocalSocket() );
    _imp->socket->connectToServer(_imp->comServerPipePath, QLocalSocket::ReadWrite);

    if ( !_imp->socket->waitForConnected() ) {
        std::cerr << "Failed to connect local socket to " << _imp->comServerPipePath.toStdString() << std::endl;

        return;
    }

    for (;; ) {
        {
            QMutexLocker k(&_imp->mustQuitMutex);
            if (_imp->mustQuit) {
                _imp->mustQuit = false;
                _imp->mustQuitCond.wakeOne();

                return;
            }
        }


        //Sleep until we need to check again
        msleep(NATRON_BREAKPAD_CHECK_FOR_CRASH_REPORTER_EXISTENCE_MS);


        qint64 writeOK;
        {
            QString tosend(_imp->checkMessage);
            tosend.push_back( QChar::fromLatin1('\n') );
            writeOK = _imp->socket->write( tosend.toStdString().c_str() );
        }
        if (writeOK >= 0) {
            _imp->socket->flush();

            bool receivedAcknowledgement = false;
            while ( _imp->socket->waitForReadyRead(NATRON_BREAKPAD_WAIT_FOR_CRASH_REPORTER_ACK_MS) ) {
                //we received something, if it's not the ackknowledgement packet, recheck
                QString str = QString::fromUtf8( _imp->socket->readLine() );
                while ( str.endsWith( QChar::fromLatin1('\n') ) ) {
                    str.chop(1);
                }
                if (str == _imp->acknowledgementMessage) {
                    receivedAcknowledgement = true;
                    break;
                }
            }

            if (!receivedAcknowledgement) {
                std::cerr << tr("Crash reporter process does not seem to be responding anymore. This pipe %1 might be used somewhere else.").arg(_imp->comServerPipePath).toStdString() << std::endl;
                /*
                   We did not receive te acknowledgement, hence quit
                 */
                Q_EMIT otherProcessUnreachable();

                return;
            }
        }
    } // for(;;)
} // ExistenceCheckerThread::run