CVS update: JGroups/src/org/jgroups/protocols FRAG2.java

"Bela Ban" <[email protected]>
Newsgroups gmane.comp.java.javagroups.cvs
Message-ID <[email protected]>
  User: belaban 
  Date: 10/08/26 15:41:29

  Modified:    src/org/jgroups/protocols FRAG2.java
  Log:
  copies the headers only for the first fragment
  
  Revision  Changes    Path
  1.54      +7 -7      JGroups/src/org/jgroups/protocols/FRAG2.java
  
  Index: FRAG2.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/protocols/FRAG2.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- FRAG2.java	5 Mar 2010 09:04:54 -0000	1.53
  +++ FRAG2.java	26 Aug 2010 15:41:29 -0000	1.54
  @@ -37,7 +37,7 @@
    * message, so we add a constant (200 bytes).
    * 
    * @author Bela Ban
  - * @version $Id: FRAG2.java,v 1.53 2010/03/05 09:04:54 belaban Exp $
  + * @version $Id: FRAG2.java,v 1.54 2010/08/26 15:41:29 belaban Exp $
    */
   @MBean(description="Fragments messages larger than fragmentation size into smaller packets")
   @DeprecatedProperty(names={"overhead"})
  @@ -243,12 +243,13 @@
                   log.trace(sb.toString());
               }
   
  -            long id=getNextId(); // used as a seqno
  +            long frag_id=getNextId(); // used as a seqno
               for(int i=0; i < fragments.size(); i++) {
                   Range r=fragments.get(i);
  -                Message frag_msg=msg.copy(false); // don't copy the buffer, only src, dest and headers. But do copy the headers
  +                // don't copy the buffer, only src, dest and headers. Only copy the headers one time !
  +                Message frag_msg=msg.copy(false, i == 0);
                   frag_msg.setBuffer(buffer, (int)r.low, (int)r.high);
  -                FragHeader hdr=new FragHeader(id, i, num_frags);
  +                FragHeader hdr=new FragHeader(frag_id, i, num_frags);
                   frag_msg.putHeader(this.id, hdr);
                   down_prot.down(new Event(Event.MSG, frag_msg));
               }
  @@ -405,12 +406,11 @@
               int     combined_length=0, length, offset;
               int     index=0;
   
  -            for(Message fragment: fragments) {
  +            for(Message fragment: fragments)
                   combined_length+=fragment.getLength();
  -            }
   
               combined_buffer=new byte[combined_length];
  -            retval=fragments[0].copy(false);
  +            retval=fragments[0].copy(false); // doesn't copy the payload, but copies the headers
   
               for(int i=0; i < fragments.length; i++) {
                   Message fragment=fragments[i];
  
  
  

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.