Changeset 4a029b7


Ignore:
Timestamp:
Nov 18, 2004 7:42:11 PM (16 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ed8eced
Parents:
6bd9e58
git-author:
jrandom <jrandom> (11/18/04 19:42:11)
git-committer:
zzz <zzz@…> (11/18/04 19:42:11)
Message:
  • if we timeout connecting or otherwise need to cancel tags that we've sent, go one step further and cancel all of the tags we're using for that peer so that we can react to their potential restart / tag loss quicker.
  • use the minimum resend delay as the base to be exponentiated if our RTT is too low (so we resend less)
  • dont be such a wuss when flushing a closed stream
Location:
apps/streaming/java/src/net/i2p/client/streaming
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/streaming/java/src/net/i2p/client/streaming/Connection.java

    r6bd9e58 r4a029b7  
    337337        } else {
    338338            doClose();
     339            boolean tagsCancelled = false;
    339340            synchronized (_outboundPackets) {
    340341                for (Iterator iter = _outboundPackets.values().iterator(); iter.hasNext(); ) {
    341342                    PacketLocal pl = (PacketLocal)iter.next();
     343                    if ( (pl.getTagsSent() != null) && (pl.getTagsSent().size() > 0) )
     344                        tagsCancelled = true;
    342345                    pl.cancelled();
    343346                }
     
    345348                _outboundPackets.notifyAll();
    346349            }
     350            if (tagsCancelled)
     351                _context.sessionKeyManager().failTags(_remotePeer.getPublicKey());
    347352        }
    348353        if (removeFromConMgr) {
     
    380385            _connectionManager.removeConnection(this);
    381386        }
    382        
     387
     388        boolean tagsCancelled = false;
    383389        synchronized (_outboundPackets) {
    384390            for (Iterator iter = _outboundPackets.values().iterator(); iter.hasNext(); ) {
    385391                PacketLocal pl = (PacketLocal)iter.next();
     392                if ( (pl.getTagsSent() != null) && (pl.getTagsSent().size() > 0) )
     393                    tagsCancelled = true;
    386394                pl.cancelled();
    387395            }
    388396            _outboundPackets.clear();
    389397            _outboundPackets.notifyAll();
    390         }
     398        }           
     399        if (tagsCancelled)
     400            _context.sessionKeyManager().failTags(_remotePeer.getPublicKey());
     401
    391402    }
    392403   
     
    673684       
    674685        public void timeReached() {
    675             if (!_connected) return;
     686            if (_packet.getAckTime() > 0)
     687                return;
     688           
     689            if (!_connected) {
     690                _packet.cancelled();
     691                return;
     692            }
    676693           
    677694            //if (_log.shouldLog(Log.DEBUG))
     
    733750                    if (_log.shouldLog(Log.DEBUG))
    734751                        _log.debug("Too many resends");
     752                    _packet.cancelled();
    735753                    disconnect(false);
    736754                } else {
    737755                    //long timeout = _options.getResendDelay() << numSends;
    738                     long timeout = _options.getRTT() << (numSends-1);
    739                     if (timeout < MIN_RESEND_DELAY)
    740                         timeout = MIN_RESEND_DELAY;
     756                    long rtt = _options.getRTT();
     757                    if (rtt < MIN_RESEND_DELAY)
     758                        rtt = MIN_RESEND_DELAY;
     759                    long timeout = rtt << (numSends-1);
    741760                    if ( (timeout > MAX_RESEND_DELAY) || (timeout <= 0) )
    742761                        timeout = MAX_RESEND_DELAY;
  • apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java

    r6bd9e58 r4a029b7  
    198198        WriteStatus ws = null;
    199199        synchronized (_dataLock) {
    200             if (_buf == null) throw new IOException("closed (buffer went away)");
     200            // _buf may be null, but the data receiver can handle that just fine,
     201            // deciding whether or not to send a packet
    201202            ws = target.writeData(_buf, 0, _valid);
    202203            _written += _valid;
     
    204205            _dataLock.notifyAll();
    205206        }
    206         if (blocking) {
     207        if (blocking && ws != null) {
    207208            ws.waitForAccept(_writeTimeout);
    208209            if (ws.writeFailed())
Note: See TracChangeset for help on using the changeset viewer.