TEST(LockManager, CompatibleFirstCancelWaiting) { LockManager lockMgr; const ResourceId resId(RESOURCE_GLOBAL, 0); MMAPV1LockerImpl lockerSInitial; LockRequestCombo requestSInitial(&lockerSInitial); ASSERT(LOCK_OK == lockMgr.lock(resId, &requestSInitial, MODE_S)); MMAPV1LockerImpl lockerX; LockRequestCombo requestX(&lockerX); ASSERT(LOCK_WAITING == lockMgr.lock(resId, &requestX, MODE_X)); MMAPV1LockerImpl lockerPending; LockRequestCombo requestPending(&lockerPending); requestPending.compatibleFirst = true; ASSERT(LOCK_WAITING == lockMgr.lock(resId, &requestPending, MODE_S)); // S1 is not granted yet, so the policy should still be FIFO { MMAPV1LockerImpl lockerS; LockRequestCombo requestS(&lockerS); ASSERT(LOCK_WAITING == lockMgr.lock(resId, &requestS, MODE_S)); ASSERT(lockMgr.unlock(&requestS)); } // Unlock S1, the policy should still be FIFO ASSERT(lockMgr.unlock(&requestPending)); { MMAPV1LockerImpl lockerS; LockRequestCombo requestS(&lockerS); ASSERT(LOCK_WAITING == lockMgr.lock(resId, &requestS, MODE_S)); ASSERT(lockMgr.unlock(&requestS)); } // Unlock remaining locks to keep the leak detection logic happy ASSERT(lockMgr.unlock(&requestSInitial)); ASSERT(lockMgr.unlock(&requestX)); }
void HTTPTracker::doRequest(WaitJob* wjob) { KUrl u = url; if (!url.isValid()) { requestPending(); QTimer::singleShot(500, this, SLOT(emitInvalidURLFailure())); return; } Uint16 port = ServerInterface::getPort(); u.addQueryItem("peer_id", peer_id.toString()); u.addQueryItem("port", QString::number(port)); u.addQueryItem("uploaded", QString::number(bytesUploaded())); u.addQueryItem("downloaded", QString::number(bytesDownloaded())); if (event == "completed") u.addQueryItem("left", "0"); // need to send 0 when we are completed else u.addQueryItem("left", QString::number(tds->bytesLeft())); u.addQueryItem("compact", "1"); if (event != "stopped") u.addQueryItem("numwant", "200"); else u.addQueryItem("numwant", "0"); u.addQueryItem("key", QString::number(key)); QString cip = Tracker::getCustomIP(); if (cip.isNull()) cip = CurrentIPv6Address(); if (!cip.isEmpty()) u.addQueryItem("ip", cip); if (event.isEmpty() && supports_partial_seed_extension && tds->isPartialSeed()) event = "paused"; if (!event.isEmpty()) u.addQueryItem("event", event); QString epq = u.encodedPathAndQuery(); const SHA1Hash & info_hash = tds->infoHash(); epq += "&info_hash=" + info_hash.toURLString(); u.setEncodedPathAndQuery(epq); if (active_job) { announce_queue.append(u); Out(SYS_TRK | LOG_NOTICE) << "Announce ongoing, queueing announce" << endl; } else { doAnnounce(u); // if there is a wait job, add this job to the waitjob if (wjob) wjob->addExitOperation(new ExitJobOperation(active_job)); } }