Update of /cvsroot/freenet/freenet/src/freenet/transport
In directory sc8-pr-cvs1:/tmp/cvs-serv19780/src/freenet/transport

Modified Files:
        AbstractSelectorLoop.java 
Log Message:
6283:
Set new threads to NORMAL priority level. Hopefully this won't fsck up people's 
efforts to nice freenet... it seems to be necessary under some platforms because the 
ticker is at max priority and they inherit by default.
Don't close the selector if it's already closed in ASL.reset(), catch any throwables 
caught by closing and try to reopen anyway. Documet mySelect. Catch 
ClosedSelectorException and try to handle it in mySelect.
Fix NPE in ConnectionHandler.
Logging.


Index: AbstractSelectorLoop.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/transport/AbstractSelectorLoop.java,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -w -r1.84 -r1.85
--- AbstractSelectorLoop.java   25 Oct 2003 10:44:45 -0000      1.84
+++ AbstractSelectorLoop.java   28 Oct 2003 03:02:50 -0000      1.85
@@ -377,7 +377,15 @@
                }
                
                try {
+                       if(sel.isOpen()) {
+                               try {
                        sel.close();
+                               } catch (Throwable t) {
+                                       Core.logger.log(this, "Caught "+t+" closing 
selector in reset()",
+                                                                       t, 
Logger.ERROR);
+                               }
+                               // Try open() anyway
+                       }
                        
                        sel = Selector.open();
                        
@@ -479,6 +487,11 @@
                }
        }
        
+       /**
+        * Do a selection operation
+        * @return true if we selected, false if something failed, the usual
+        * response would be to try again
+        */
        protected final boolean mySelect(int x) throws IOException {
                boolean windowsBugHappened = false;
                try{
@@ -581,6 +594,20 @@
                                }
                                return false;
                        } else throw e;
+               } catch (ClosedSelectorException e) {
+                       Core.logger.log(this, "WTF?!: "+e, e,
+                                                       Logger.ERROR);
+                       try {
+                               reset();
+                       } catch (Throwable t) {
+                               Core.logger.log(this, "Reopening selector FAILED!: 
"+t, t,
+                                                               Logger.ERROR);
+                               System.err.println("Reopening selector FAILED! Tried 
to handle: "+e);
+                               e.printStackTrace(System.err);
+                               System.err.println("But then caught: "+t);
+                               t.printStackTrace(System.err);
+                       }
+                       return false;
                }
                if(!windowsBugHappened)
                        this.consecutiveWindowsBugEncounters =0;

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

Reply via email to