Changeset 6d4a9ab


Ignore:
Timestamp:
Dec 9, 2011 4:41:41 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
937ae8ad
Parents:
533f762
Message:
  • Fix major bug from 2005 that corrupted outbound messages that were an exact multiple of the fragment size.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/udp/OutboundMessageState.java

    r533f762 r6d4a9ab  
    149149    public PeerState getPeer() { return _peer; }
    150150    public void setPeer(PeerState peer) { _peer = peer; }
     151
    151152    public boolean isExpired() {
    152153        return _expiration < _context.clock().now();
    153154    }
     155
    154156    public boolean isComplete() {
    155157        short sends[] = _fragmentSends;
     
    161163        return true;
    162164    }
     165
    163166    public int getUnackedSize() {
    164167        short fragmentSends[] = _fragmentSends;
     
    181184        return rv;
    182185    }
     186
    183187    public boolean needsSending(int fragment) {
    184188       
     
    188192        return (sends[fragment] >= (short)0);
    189193    }
     194
    190195    public long getLifetime() { return _context.clock().now() - _startedOn; }
    191196   
     
    228233    public int getMaxSends() { return _maxSends; }
    229234    public int getPushCount() { return _pushCount; }
     235
    230236    /** note that we have pushed the message fragments */
    231237    public void push() {
     
    239245       
    240246    }
     247
    241248    public boolean isFragmented() { return _fragmentSends != null; }
     249
    242250    /**
    243251     * Prepare the message for fragmented delivery, using no more than
     
    259267        _fragmentSends = new short[numFragments];
    260268        //Arrays.fill(_fragmentEnd, -1);
    261         Arrays.fill(_fragmentSends, (short)0);
     269        //Arrays.fill(_fragmentSends, (short)0);
    262270       
    263271        _fragmentSize = fragmentSize;
    264272    }
     273
    265274    /** how many fragments in the message */
    266275    public int getFragmentCount() {
     
    270279            return _fragmentSends.length;
    271280    }
     281
    272282    public int getFragmentSize() { return _fragmentSize; }
     283
    273284    /** should we continue sending this fragment? */
    274285    public boolean shouldSend(int fragmentNum) { return _fragmentSends[fragmentNum] >= (short)0; }
     286
    275287    public int fragmentSize(int fragmentNum) {
    276288        if (_messageBuf == null) return -1;
     
    279291            if (valid <= _fragmentSize)
    280292                return valid;
    281             else
    282                 return valid % _fragmentSize;
     293            // bugfix 0.8.12
     294            int mod = valid % _fragmentSize;
     295            return mod == 0 ? _fragmentSize : mod;
    283296        } else {
    284297            return _fragmentSize;
Note: See TracChangeset for help on using the changeset viewer.