activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r384638 - /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/CommandChannel.java
Date Thu, 09 Mar 2006 22:57:15 GMT
Author: jstrachan
Date: Thu Mar  9 14:57:13 2006
New Revision: 384638

URL: http://svn.apache.org/viewcvs?rev=384638&view=rev
Log:
fix bug in fragmentation

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/CommandChannel.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/CommandChannel.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/CommandChannel.java?rev=384638&r1=384637&r2=384638&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/CommandChannel.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/CommandChannel.java
Thu Mar  9 14:57:13 2006
@@ -179,7 +179,6 @@
 
     public void write(Command command, SocketAddress address) throws IOException {
         synchronized (writeLock) {
-            header.incrementCounter();
 
             ByteArrayOutputStream largeBuffer = new ByteArrayOutputStream(largeMessageBufferSize);
             wireFormat.marshal(command, new DataOutputStream(largeBuffer));
@@ -187,6 +186,7 @@
             int size = data.length;
 
             if (size < datagramSize) {
+                header.incrementCounter();
                 header.setPartial(false);
                 header.setComplete(true);
                 header.setDataSize(size);
@@ -210,6 +210,10 @@
                     writeBuffer.rewind();
                     int chunkSize = writeBuffer.capacity() - headerMarshaller.getHeaderSize(header);
                     lastFragment = offset + chunkSize >= length;
+                    if (lastFragment) {
+                        chunkSize = length - offset;
+                    }
+                    header.incrementCounter();
                     header.setDataSize(chunkSize);
                     header.setComplete(lastFragment);
                     headerMarshaller.writeHeader(header, writeBuffer);



Mime
View raw message