Author: nextgens
Date: 2008-01-27 19:49:59 +0000 (Sun, 27 Jan 2008)
New Revision: 17325

Modified:
   trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java
Log:
maybe fix #2019: Socket dies if first message is not ClientHello

Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java  
2008-01-27 16:57:20 UTC (rev 17324)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java  
2008-01-27 19:49:59 UTC (rev 17325)
@@ -44,12 +44,13 @@
        private void realRun() throws IOException {
                OutputStream os = new 
BufferedOutputStream(handler.sock.getOutputStream(), 4096);
                while(true) {
-                       boolean closed;
+                       boolean closed, empty = false;
                        FCPMessage msg = null;
                        while(true) {
                                closed = handler.isClosed();
                                synchronized(outQueue) {
-                                       if(outQueue.isEmpty()) {
+                                       empty = outQueue.isEmpty();
+                                       if(empty) {
                                                if(closed) break;
                                                os.flush();
                                                try {
@@ -64,7 +65,7 @@
                                }
                        }
                        if(msg == null) {
-                               if(closed) {
+                               if(closed && empty) {
                                        os.flush();
                                        os.close();
                                        return;


Reply via email to