Hi all
My last patch did not resolve the problem correctly. Here is another patch
that hopefully does a better job. The logic is like this:
If any of these two situations happen then remove from webcache
1: HTTP Errors 403, 404 and 410
2: Any other error and this is the first time in this session.
Also locking should happen before checking the removedWebCacheThisSession
variable to avoid concurrency issues.
This has been committed. Please update your source.
Shervin
Index: Sck.cs
===================================================================
RCS file: /cvsroot/filescope/filescope/Core/Gnutella/Sck.cs,v
retrieving revision 1.3
diff -r1.3 Sck.cs
274c274,282
< if(e.Message.IndexOf("403") != -1 ||
e.Message.IndexOf("404") != -1 || e.Message.IndexOf("410") != -1)
---
> // If any of these two situations happen
then remove from webcache
> // 1: HTTP Errors 403, 404 and 410
> // 2: Any other error and this is the first
time in this session.
> bool remove = false;
>
> if (e.Message.IndexOf("403") != -1 ||
e.Message.IndexOf("404") != -1 || e.Message.IndexOf("410") != -1)
> remove = true;
>
> lock(Stats.gnutellaWebCache)
276c284
< if(!removedWebCacheThisSession)
---
> if(!removedWebCacheThisSession ||
remove)
278,285c286,293
< lock(Stats.gnutellaWebCache)
< {
< //remove it
< for(int posgwc = 0;
posgwc < Stats.gnutellaWebCache.Count; posgwc++)
<
if((string)Stats.gnutellaWebCache[posgwc] == this.address)
< {
<
System.Diagnostics.Debug.WriteLine("gwc1 removed: " + this.address);
<
Stats.gnutellaWebCache.RemoveAt(posgwc);
---
> // remove it
> for(int posgwc = 0; posgwc <
Stats.gnutellaWebCache.Count; posgwc++)
>
if((string)Stats.gnutellaWebCache[posgwc] == this.address)
> {
>
System.Diagnostics.Debug.WriteLine("gwc1 removed: " + this.address);
>
Stats.gnutellaWebCache.RemoveAt(posgwc);
>
> if (!remove)
287,289c295,297
<
return;
< }
< }
---
>
> return;
> }
292,296c300
< else
< {
<
System.Diagnostics.Debug.WriteLine("g1 wc get response error: " +
e.Message);
<
System.Diagnostics.Debug.WriteLine(e.StackTrace);
< }
---
>
|