void TransactionAcquire::onTimer (bool progress, boost::recursive_mutex::scoped_lock& psl)
{
    bool aggressive = false;

    if (getTimeouts () > 10)
    {
        WriteLog (lsWARNING, TransactionAcquire) << "Ten timeouts on TX set " << getHash ();
        psl.unlock();
        {
            Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);

            if (getApp().getOPs ().stillNeedTXSet (mHash))
            {
                WriteLog (lsWARNING, TransactionAcquire) << "Still need it";
                mTimeouts = 0;
                aggressive = true;
	    }
        }
        psl.lock();

        if (!aggressive)
        {
            mFailed = true;
            done ();
            return;
        }
    }

    if (aggressive || !getPeerCount ())
    {
        // out of peers
        WriteLog (lsWARNING, TransactionAcquire) << "Out of peers for TX set " << getHash ();

        bool found = false;
        std::vector<Peer::pointer> peerList = getApp().getPeers ().getPeerVector ();
        BOOST_FOREACH (Peer::ref peer, peerList)
        {
            if (peer->hasTxSet (getHash ()))
            {
                found = true;
                peerHas (peer);
            }
        }

        if (!found)
        {
            BOOST_FOREACH (Peer::ref peer, peerList)
            peerHas (peer);
        }
    }
Example #2
0
void GUIThread::join_joinable_threads( boost::recursive_mutex::scoped_lock& lock ) {
    /* Careful handling of this ID is necessary. At least for 
        * POSIX threads implementation, the ID keeps a handle on the
        * thread open. */
    boost::optional<boost::thread::id> next_join = joinable_threads.front();
    joinable_threads.pop();
    boost::thread* thread = active_threads[ *next_join ];
    active_threads.erase( *next_join );
    have_task.notify_all();
    lock.unlock();
    next_join.reset();
    thread->join();
    delete thread;
    lock.lock();
}