Scenario: A host has a large number of files that match a particular query. As it stands, no matter how many times another nodes issues that query, the host in question will respond with the same 50 responses.

Ideally, if the user sees a large block of matching results from one node, he could "browse host" to see if there are more than he might be of interest.

I've found from experience that a large percentage of GNet nodes have browsing disabled.

I won't pass judgement on those nodes, as they may have good reasons for keeping browsing disabled (here in the US, the RIAA routinely uses screenshots of such browses in their judicial extortion campaign).

What I think GtkG (and GNet in general) should do is randomize the results of a query, so that while we're limited to 50 responses per query, it won't necessarily be the SAME 50 each time. This way, if someone sets up a query, and leaves it active over a period of time, he will eventually see all of the possible matches.

The attached patch (to "src/core/matching.c") implements this by generating a random offset for the list of potential matches. This offset is added to the index (and wrapped around if it hits the end). This way, a query will receive different blocks of responses each time the same query is received.

Lloyd Bryant

--- matching.c.orig	2006-11-05 19:03:21.000000000 -0700
+++ matching.c	2006-11-11 08:26:08.000000000 -0700
@@ -460,10 +460,11 @@
 	guint wocnt;
 	cpattern_t **pattern;
 	struct st_entry **vals;
-	gint vcnt;
+	guint vcnt;
 	gint scanned = 0;		/* measure search mask efficiency */
 	guint32 search_mask;
 	size_t minlen;
+	guint32 random_offset;  /* Randomizer for search returns */
 
 	len = strlen(search);
 
@@ -576,12 +577,16 @@
 
 	vcnt = best_bin->nvals;
 	vals = best_bin->vals;
+	random_offset = random_value(vcnt - 1);
 
-	while (nres < max_res && vcnt-- > 0) {
-		struct st_entry *e = *vals++;
-		struct shared_file *sf = e->sf;
+	for (i = 0; (i < vcnt) && (nres < max_res); i++) {
+		struct st_entry *e;
+		struct shared_file *sf;
 		size_t canonic_len;
 
+		e = vals[(i + random_offset) % vcnt];
+		sf = e->sf;
+		
 		if ((e->mask & search_mask) != search_mask)
 			continue;		/* Can't match */
 

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Gtk-gnutella-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to