Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

queries can be marked stopped

  • Loading branch information...
commit 37d21a8e42107b3d17b3f32b79dcb58c5fd6e3f5 1 parent 81192b4
@RJ authored
Showing with 16 additions and 8 deletions.
  1. +16 −8 includes/playdar/resolver_query.hpp
View
24 includes/playdar/resolver_query.hpp
@@ -19,7 +19,6 @@
#ifndef __RESOLVER_QUERY_H__
#define __RESOLVER_QUERY_H__
-//#include "playdar/application.h"
#include "playdar/types.h"
#include "playdar/config.hpp"
#include "playdar/resolved_item.h"
@@ -41,7 +40,7 @@ class ResolverQuery
{
public:
ResolverQuery()
- : m_solved(false), m_cancelled(false), m_origin_local(false)
+ : m_solved(false), m_cancelled(false), m_stopped(false), m_origin_local(false)
{
// set initial "last access" time:
time(&m_atime);
@@ -84,6 +83,9 @@ class ResolverQuery
/// returns true if query cancelled and pending destruction. (hint, release your ptr)
bool cancelled() const { return m_cancelled; }
+ bool stopped() const { return m_stopped; }
+ void stop() { m_stopped = true; }
+
virtual json_spirit::Object get_json() const
{
time(&m_atime);
@@ -180,9 +182,10 @@ class ResolverQuery
{
if (!m_cancelled) {
boost::mutex::scoped_lock lock(m_mut);
- if (rip->score() == 1.0) {
- m_solved = true;
- }
+ // may as well still collect results, even if solved:
+ //if (rip->score() == 1.0) {
+ // m_solved = true;
+ //}
m_results.push_back(rip);
// fire callbacks:
BOOST_FOREACH(rq_callback_t & cb, m_callbacks) {
@@ -203,9 +206,10 @@ class ResolverQuery
BOOST_FOREACH(const ri_ptr& rip, results) {
// decide if this result "solves" the query:
// for now just assume score of 1 means solved.
- if(rip->score() == 1.0) {
- m_solved = true;
- }
+ // may as wel still collect results, even if solved:
+ //if(rip->score() == 1.0) {
+ // m_solved = true;
+ //}
// fire callbacks:
BOOST_FOREACH(rq_callback_t & cb, m_callbacks) {
cb(id(), rip);
@@ -292,6 +296,10 @@ class ResolverQuery
// set to true if trying to cancel/delete this query (if so, don't bother working with it)
bool m_cancelled;
+
+ // set to true once query origin has a result, gives up or times out
+ // (especially useful in query-flooding environments like p2p)
+ bool m_stopped;
// last access time (used to know if this query is stale and can be deleted)
// mutable: it's auto-updated to mark the atime in various places.
Please sign in to comment.
Something went wrong with that request. Please try again.