Author: toad
Date: 2007-08-09 14:27:30 +0000 (Thu, 09 Aug 2007)
New Revision: 14562

Modified:
   trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
Log:
Tell the client we are shutting down, and exit, if we are shutting down. So it 
won't keep issuing more requests, but maybe we can handle the existing ones.

Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java   
2007-08-09 13:49:05 UTC (rev 14561)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java   
2007-08-09 14:27:30 UTC (rev 14562)
@@ -6,6 +6,8 @@
 import java.io.IOException;
 import java.io.InputStream;

+import org.tanukisoftware.wrapper.WrapperManager;
+
 import freenet.support.Logger;
 import freenet.support.OOMHandler;
 import freenet.support.SimpleFieldSet;
@@ -49,6 +51,16 @@

                while(true) {
                        SimpleFieldSet fs;
+                       if(WrapperManager.hasShutdownHookBeenTriggered()) {
+                               FCPMessage msg = new 
ProtocolErrorMessage(ProtocolErrorMessage.SHUTTING_DOWN,true,"The node is 
shutting down","Node",false);
+                               handler.outputHandler.queue(msg);
+                               try {
+                                       is.close();
+                               } catch (IOException e) {
+                                       // Don't care
+                               }
+                               return;
+                       }
                        // Read a message
                        String messageType = lis.readLine(128, 128, true);
                        if(messageType == null) {


Reply via email to