Author: fhanik
Date: Thu Apr 13 14:20:21 2006
New Revision: 393944

URL: http://svn.apache.org/viewcvs?rev=393944&view=rev
Log:
Fixed, when reusing a send buffer need to set the limit

Modified:
    
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioSender.java

Modified: 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioSender.java
URL: 
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioSender.java?rev=393944&r1=393943&r2=393944&view=diff
==============================================================================
--- 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioSender.java
 (original)
+++ 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioSender.java
 Thu Apr 13 14:20:21 2006
@@ -173,7 +173,6 @@
             if ( remaining > 0 ) {
                 //weve written everything, or we are starting a new package
                 //protect against buffer overwrite
-                int length = current.length-curPos;
                 int byteswritten = socketChannel.write(writebuf);
                 curPos += byteswritten;
                 remaining -= byteswritten;
@@ -291,16 +290,16 @@
    public synchronized void setMessage(byte[] data,int offset, int length) 
throws IOException {
        if ( data != null ) {
            current = data;
-           remaining = current.length;
-           curPos = 0;
+           remaining = length;
+           curPos = offset;
            ackbuf.clear();
-//todo, reuse the buffers, this causes problems on windows
-//           if ( writebuf != null ) writebuf.clear();
-//           else writebuf = getBuffer(length);
-           writebuf = getBuffer(length);
+           if ( writebuf != null ) writebuf.clear();
+           else writebuf = getBuffer(length);
            if ( writebuf.capacity() < length ) writebuf = getBuffer(length);
            writebuf.put(data,offset,length);
            writebuf.rewind();
+           //set the limit so that we don't write non wanted data
+           writebuf.limit(length);
            if (isConnected()) {
                socketChannel.register(getSelector(), SelectionKey.OP_WRITE, 
this);
            }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to