dev@grizzly.java.net

OutputWrite write()>=0

From: ÏòÇØÏÍ <fyaoxy_at_gmail.com>
Date: Tue, 24 Jul 2007 10:07:07 +0800

Hi Jeanfrancois£¬
Do you remember my comments on your blog on grizzly tricks and tips:)
I checked out write operation again and give a patch.
maybe you can check it.

Index:
F:/svn/grizzly/modules/grizzly/src/main/java/com/sun/grizzly/util/OutputWriter.java
===================================================================
---
F:/svn/grizzly/modules/grizzly/src/main/java/com/sun/grizzly/util/OutputWriter.java
(revision 394)
+++
F:/svn/grizzly/modules/grizzly/src/main/java/com/sun/grizzly/util/OutputWriter.java
(working copy)
@@ -86,14 +86,13 @@
         try {
             while ( bb.hasRemaining() ) {
                 int len = socketChannel.write(bb);
-                attempts++;
-                if (len < 0){
-                    throw new EOFException();
-                }
-
-                bytesProduced += len;
-
-                if (len == 0) {
+                if (len>0){
+                    attempts = 0;
+                    bytesProduced += len;
+                }else {
+                    //handle write count = 0;NOTE write() return result
>=0, no <0 exist.
+                    attempts++;
+
                     if ( writeSelector == null ){
                         writeSelector = SelectorFactory.getSelector();
                         if ( writeSelector == null){
@@ -111,8 +110,7 @@
                     } else {
                         attempts--;
                     }
-                } else {
-                    attempts = 0;
+                    //handle write count = 0 end;
                 }
             }
         } finally {
-- 
Ö¾´
ÏòÇØÏÍ