Update of /cvsroot/freenet/freenet/src/freenet/node
In directory sc8-pr-cvs1:/tmp/cvs-serv25689/freenet/src/freenet/node

Modified Files:
        FailureTable.java 
Log Message:
Add support for FailureEntrys w/o FailItems which are there for ignoring DNFs only.

Index: FailureTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/FailureTable.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -r1.32 -r1.33
--- FailureTable.java   3 Nov 2003 22:59:16 -0000       1.32
+++ FailureTable.java   4 Nov 2003 01:24:56 -0000       1.33
@@ -258,6 +258,10 @@
                        return false;
                }
                
+               public boolean expired(long now) {
+                       return (time + maxMillis < now);
+               }
+               
                public void remove() {
                        items.remove(this);
                }
@@ -314,9 +318,10 @@
                 */
                public void removeItem(FailItem fi) {
                        myItems.remove(fi);
-                       if ( myItems.size() == 0 ) {
-                               remove();
-                       }
+                       //FailureEntries need not have any FailureItems if they are in 
'pass-through' mode
+//                     if ( myItems.size() == 0 ) {
+//                             remove();
+//                     }
                }
                
                /**
@@ -353,7 +358,13 @@
                public long shouldFail(int hopsToLive, long time) {
                        long failedTime=-1;
                        for(Iterator i = myItems.iterator();i.hasNext();) {
-                               if( 
(failedTime=((FailItem)i.next()).shouldFail(hopsToLive,time)) >= 0 ) {
+                               FailItem fi = (FailItem)i.next();
+                               if ( fi.expired(time) ) {
+                                       fi.remove();
+                                       i.remove();
+                                       continue;
+                               }
+                               if( (failedTime=fi.shouldFail(hopsToLive,time)) >= 0 ) 
{
                                        blocks++;
                                        totalBlocks++;
                                        
Core.diagnostics.occurrenceContinuous("timeBetweenFailedRequests",
@@ -387,15 +398,18 @@
                 */
                public void toHtml(PrintWriter pw, long time) {
                        boolean active = (time - lastFail) < maxMillis;
-                       pw.println("<tr><td rowspan="+myItems.size()+"><font size=-2 
color=\"" + (active ? "red" : "green") 
+                       int span = Math.max(myItems.size(),1);
+                       pw.println("<tr><td rowspan="+span+"><font size=-2 color=\"" + 
(active ? "red" : "green") 
                                                + "\">" + key + "</font></td>");
                        Iterator i = myItems.iterator();
                        if ( i.hasNext() ) {
                                ((FailItem)(i.next())).toHtml(pw,time);
+                       } else {
+                               pw.println("<td>&nbsp;</td><td>&nbsp;</td>");
                        }
-                       pw.println("<td rowspan="+myItems.size()+">" + blocks
-                                               + "</td><td 
rowspan="+myItems.size()+">" +  ignores
-                                               + "</td><td 
rowspan="+myItems.size()+">" + new Date(lastHit) + "</td></tr>");
+                       pw.println("<td rowspan="+span+">" + blocks
+                                               + "</td><td rowspan="+span+">" +  
ignores
+                                               + "</td><td rowspan="+span+">" + new 
Date(lastHit) + "</td></tr>");
                        for ( ; i.hasNext(); ) {
                                pw.print("<tr>");
                                ((FailItem)(i.next())).toHtml(pw,time);

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to