[Filescope-devel] Gnutella2 WebCache remove patch.
Brought to you by:
mzyzik
|
From: Shervin <She...@sh...> - 2005-02-22 08:32:06
|
This did not get to the mailing list so I am resending it.
Hi all
This patch resolves the issue of more than one Gnutella2 webcache being
deleted in one session. The line causing this problem was
(Core/Gnutella2/Sck.cs:391):
if(remove || !removedWebCacheToday)
It should have been
if(remove && !removedWebCacheToday)
I also got rid of the remove variable and added HTTP error 410: Gone to the
list.
This patch is now in CVS.
Shervin
Index: Sck.cs
===================================================================
RCS file: /cvsroot/filescope/filescope/Core/Gnutella2/Sck.cs,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 Sck.cs
103a104,106
> // We use this flag to prevent too many webcaches to be
removed
> static bool removedWebCacheThisSession = false;
>
388,391c391,392
< bool remove = false;
< if(e.Message.IndexOf("404") != -1 ||
e.Message.IndexOf("403") != -1)
< remove = true;
< if(remove || !removedWebCacheToday)
---
>
> if(e.Message.IndexOf("403") != -1 ||
e.Message.IndexOf("404") !=
> -1 || e.Message.IndexOf("410") != -1)
393c394
< lock(Stats.gnutella2WebCache)
---
> if(!removedWebCacheThisSession)
395,402c396,406
< for(int posgwc = 0; posgwc <
Stats.gnutella2WebCache.Count; posgwc++)
<
if((string)Stats.gnutella2WebCache[posgwc] == this.address)
< {
<
System.Diagnostics.Debug.WriteLine("gwc2 removed: " + this.address);
<
Stats.gnutella2WebCache.RemoveAt(posgwc);
<
removedWebCacheToday = true;
< return;
< }
---
>
lock(Stats.gnutella2WebCache)
> {
> for(int posgwc = 0;
posgwc < Stats.gnutella2WebCache.Count; posgwc++)
>
if((string)Stats.gnutella2WebCache[posgwc] == this.address)
> {
>
System.Diagnostics.Debug.WriteLine("gwc2 removed: " + this.address);
>
Stats.gnutella2WebCache.RemoveAt(posgwc);
>
removedWebCacheThisSession = true;
>
return;
> }
> }
409,411d412
< //we use this flag to prevent too many webcaches to be
removed
< static bool removedWebCacheToday = false;
<
|