Changeset a11bd7cb for router


Ignore:
Timestamp:
Feb 8, 2017 3:22:41 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f0241d4
Parents:
36ec4de
Message:

I2CP: Return local delivery failure on queue overflow (ticket #1939)

Location:
router/java/src/net/i2p/router/client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/client/ClientConnectionRunner.java

    r36ec4de ra11bd7cb  
    721721   
    722722    /**
    723      * Asynchronously deliver the message to the current runner
    724      *
    725      * Note that no failure indication is available.
    726      * Fails silently on e.g. queue overflow to client, client dead, etc.
     723     * Synchronously deliver the message to the current runner
     724     *
     725     * Failure indication is available as of 0.9.29.
     726     * Fails on e.g. queue overflow to client, client dead, etc.
    727727     *
    728728     * @param toDest non-null
    729729     * @param fromDest generally null when from remote, non-null if from local
     730     * @return success
    730731     */
    731     void receiveMessage(Destination toDest, Destination fromDest, Payload payload) {
    732         if (_dead) return;
     732    boolean receiveMessage(Destination toDest, Destination fromDest, Payload payload) {
     733        if (_dead)
     734            return false;
    733735        MessageReceivedJob j = new MessageReceivedJob(_context, this, toDest, fromDest, payload, _dontSendMSMOnReceive);
    734736        // This is fast and non-blocking, run in-line
    735737        //_context.jobQueue().addJob(j);
    736         j.runJob();
    737     }
    738    
    739     /**
    740      * Asynchronously deliver the message to the current runner
    741      *
    742      * Note that no failure indication is available.
    743      * Fails silently on e.g. queue overflow to client, client dead, etc.
     738        //j.runJob();
     739        return j.receiveMessage();
     740    }
     741   
     742    /**
     743     * Synchronously deliver the message to the current runner
     744     *
     745     * Failure indication is available as of 0.9.29.
     746     * Fails on e.g. queue overflow to client, client dead, etc.
    744747     *
    745748     * @param toHash non-null
    746749     * @param fromDest generally null when from remote, non-null if from local
     750     * @return success
    747751     * @since 0.9.21
    748752     */
    749     void receiveMessage(Hash toHash, Destination fromDest, Payload payload) {
     753    boolean receiveMessage(Hash toHash, Destination fromDest, Payload payload) {
    750754        SessionParams sp = _sessions.get(toHash);
    751755        if (sp == null) {
    752756            if (_log.shouldLog(Log.WARN))
    753757                _log.warn("No session found for receiveMessage()");
    754             return;
    755         }
    756         receiveMessage(sp.dest, fromDest, payload);
     758            return false;
     759        }
     760        return receiveMessage(sp.dest, fromDest, payload);
    757761    }
    758762   
  • router/java/src/net/i2p/router/client/ClientManager.java

    r36ec4de ra11bd7cb  
    418418
    419419        public void runJob() {
    420             _to.receiveMessage(_toDest, _fromDest, _payload);
    421             // note that receiveMessage() does not indicate a failure,
    422             // so a queue overflow is not recognized. we always return success.
     420            boolean ok = _to.receiveMessage(_toDest, _fromDest, _payload);
    423421            if (_from != null) {
    424                 _from.updateMessageDeliveryStatus(_fromDest, _msgId, _messageNonce, MessageStatusMessage.STATUS_SEND_SUCCESS_LOCAL);
     422                int rc = ok ? MessageStatusMessage.STATUS_SEND_SUCCESS_LOCAL : MessageStatusMessage.STATUS_SEND_FAILURE_LOCAL;
     423                _from.updateMessageDeliveryStatus(_fromDest, _msgId, _messageNonce, rc);
    425424            }
    426425        }
  • router/java/src/net/i2p/router/client/MessageReceivedJob.java

    r36ec4de ra11bd7cb  
    4949
    5050    public void runJob() {
    51         if (_runner.isDead()) return;
     51        receiveMessage();
     52    }
     53
     54    /**
     55     *  Same as runJob() but with a return value
     56     *  @return success
     57     *  @since 0.9.29
     58     */
     59    public boolean receiveMessage() {
     60        if (_runner.isDead())
     61            return false;
    5262        MessageId id = null;
    5363        try {
     
    6070                messageAvailable(id, _payload.getSize());
    6171            }
     72            return true;
    6273        } catch (I2CPMessageException ime) {
    6374            String msg = "Error sending data to client " + _runner.getDestHash();
     
    6879            if (id != null && !_sendDirect)
    6980                _runner.removePayload(id);
     81            return false;
    7082        }
    7183    }
Note: See TracChangeset for help on using the changeset viewer.