Changeset b5ed39f1


Ignore:
Timestamp:
Jul 28, 2018 9:44:56 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
a51d260
Parents:
f12dbba
Message:

Streaming: Throw exception on read timeout (ticket #2292)
Log tweaks

Files:
5 edited

Legend:

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

    rf12dbba rb5ed39f1  
    3838     * What is the longest we'll block on the input stream while waiting
    3939     * for more data.  If this value is exceeded, the read() throws
    40      * InterruptedIOException - FIXME doesn't really, returns -1 or 0 instead.
     40     * SocketTimeoutException as of 0.9.36.
     41     * Prior to that, the read() returned -1 or 0.
    4142     *
    4243     * WARNING: Default -1 (unlimited), which is probably not what you want.
     
    4950     * What is the longest we'll block on the input stream while waiting
    5051     * for more data.  If this value is exceeded, the read() throws
    51      * InterruptedIOException - FIXME doesn't really, returns -1 or 0 instead.
     52     * SocketTimeoutException as of 0.9.36.
     53     * Prior to that, the read() returned -1 or 0.
    5254     *
    5355     * WARNING: Default -1 (unlimited), which is probably not what you want.
  • apps/streaming/java/src/net/i2p/client/streaming/impl/I2PSocketOptionsImpl.java

    rf12dbba rb5ed39f1  
    145145     * What is the longest we'll block on the input stream while waiting
    146146     * for more data.  If this value is exceeded, the read() throws
    147      * InterruptedIOException - FIXME doesn't really, returns -1 or 0 instead.
     147     * SocketTimeoutException as of 0.9.36.
     148     * Prior to that, the read() returned -1 or 0.
    148149     *
    149150     * WARNING: Default -1 (unlimited), which is probably not what you want.
     
    158159     * What is the longest we'll block on the input stream while waiting
    159160     * for more data.  If this value is exceeded, the read() throws
    160      * InterruptedIOException - FIXME doesn't really, returns -1 or 0 instead.
     161     * SocketTimeoutException as of 0.9.36.
     162     * Prior to that, the read() returned -1 or 0.
    161163     *
    162164     * WARNING: Default -1 (unlimited), which is probably not what you want.
  • apps/streaming/java/src/net/i2p/client/streaming/impl/MessageInputStream.java

    rf12dbba rb5ed39f1  
    44import java.io.InputStream;
    55import java.io.InterruptedIOException;
     6import java.net.SocketTimeoutException;
    67import java.util.ArrayList;
    78import java.util.HashMap;
     
    353354                    _highestReadyBlockId++;
    354355                }
    355                                         // FIXME Javadocs for setReadTimeout() say we will throw
    356                                         // an InterruptedIOException.
    357                                         // Java throws a SocketTimeoutException.
    358                                         // We do neither.
    359356            } else {
    360357                // _notYetReadyBlocks size is limited in canAccept()
     
    376373   
    377374    /**
    378      *  On a read timeout, this returns -1
    379      *  (doesn't throw SocketTimeoutException like Socket)
    380      *  (doesn't throw InterruptedIOException like our javadocs say)
     375     *  On a read timeout, this throws a SocketTimeoutException
     376     *  as of 0.9.36. Prior to that, returned -1.
    381377     */
    382378    public int read() throws IOException {
     
    388384   
    389385    /**
    390      *  On a read timeout, this returns 0
    391      *  (doesn't throw SocketTimeoutException like Socket)
    392      *  (doesn't throw InterruptedIOException like our javadocs say)
     386     *  On a read timeout, this throws a SocketTimeoutException
     387     *  as of 0.9.36. Prior to that, returned 0.
    393388     */
    394389    @Override
     
    398393   
    399394    /**
    400      *  On a read timeout, this returns 0
    401      *  (doesn't throw SocketTimeoutException like Socket)
    402      *  (doesn't throw InterruptedIOException like our javadocs say)
     395     *  On a read timeout, this throws a SocketTimeoutException
     396     *  as of 0.9.36. Prior to that, returned 0.
    403397     */
    404398    @Override
     
    410404        else
    411405            expiration = -1;
     406        // for speed
     407        final boolean shouldDebug = _log.shouldDebug();
    412408        synchronized (_dataLock) {
    413409            if (_locallyClosed) throw new IOException("Input stream closed");
     
    425421                            if (_log.shouldLog(Log.INFO))
    426422                                _log.info("read(...," + offset + ", " + length + ")[" + i
    427                                            + "] got EOF after " + _readTotal + " " + toString());
     423                                           + "] got EOF after " + _readTotal + ": " + hashCode());
    428424                            return -1;
    429425                        } else {
    430426                            if (readTimeout < 0) {
    431                                 if (_log.shouldLog(Log.DEBUG))
     427                                if (shouldDebug)
    432428                                    _log.debug("read(...," + offset+", " + length+ ")[" + i
    433                                                + "] with no timeout: " + toString());
     429                                               + "] wait w/o timeout: " + hashCode());
    434430                                try {
    435431                                    _dataLock.wait();
     
    439435                                    throw ioe2;
    440436                                }
    441                                 if (_log.shouldLog(Log.DEBUG))
     437                                if (shouldDebug)
    442438                                    _log.debug("read(...," + offset+", " + length+ ")[" + i
    443                                                + "] with no timeout complete: " + toString());
     439                                               + "] wait w/o timeout complete: " + hashCode());
    444440                                throwAnyError();
    445441                            } else if (readTimeout > 0) {
    446                                 if (_log.shouldLog(Log.DEBUG))
     442                                if (shouldDebug)
    447443                                    _log.debug("read(...," + offset+", " + length+ ")[" + i
    448                                                + "] with timeout: " + readTimeout + ": " + toString());
     444                                               + "] wait: " + readTimeout + ": " + hashCode());
    449445                                try {
    450446                                    _dataLock.wait(readTimeout);
     
    454450                                    throw ioe2;
    455451                                }
    456                                 if (_log.shouldLog(Log.DEBUG))
     452                                if (shouldDebug)
    457453                                    _log.debug("read(...," + offset+", " + length+ ")[" + i
    458                                                + "] with timeout complete: " + readTimeout + ": " + toString());
     454                                               + "] wait complete: " + readTimeout + ": " + hashCode());
    459455                                throwAnyError();
    460456                            } else { // readTimeout == 0
    461457                                // noop, don't block
    462                                 if (_log.shouldLog(Log.DEBUG))
     458                                if (shouldDebug)
    463459                                    _log.debug("read(...," + offset+", " + length+ ")[" + i
    464                                                + "] with nonblocking setup: " + toString());
    465                                 return i;
     460                                               + "] nonblocking return: " + hashCode());
     461                                return 0;
    466462                            }
    467463                            if (_readyDataBlocks.isEmpty()) {
     
    469465                                    long remaining = expiration - System.currentTimeMillis();
    470466                                    if (remaining <= 0) {
    471                                         // FIXME Javadocs for setReadTimeout() say we will throw
    472                                         // an InterruptedIOException.
    473                                         // Java throws a SocketTimeoutException.
    474                                         // We do neither.
    475467                                        if (_log.shouldLog(Log.INFO))
    476468                                            _log.info("read(...," + offset+", " + length+ ")[" + i
    477                                                        + "] expired: " + toString());
    478                                         return i;
     469                                                       + "] timed out: " + hashCode());
     470                                        throw new SocketTimeoutException();
    479471                                    } else {
    480472                                        readTimeout = (int) remaining;
     
    487479                    i--;
    488480                } else if (_readyDataBlocks.isEmpty()) {
    489                     if (_log.shouldLog(Log.DEBUG))
     481                    if (shouldDebug)
    490482                        _log.debug("read(...," + offset+", " + length+ ")[" + i
    491483                                   + "] no more ready blocks, returning");
     
    503495                    target[offset + i] = rv; // rv < 0 ? rv + 256 : rv
    504496                    if ( (_readyDataBlockIndex <= 3) || (_readyDataBlockIndex >= cur.getValid() - 5) ) {
    505                         if (_log.shouldLog(Log.DEBUG))
     497                        if (shouldDebug)
    506498                            _log.debug("read(...," + offset+", " + length+ ")[" + i
    507499                                       + "] after ready data: readyDataBlockIndex=" + _readyDataBlockIndex
     
    515507        }  // synchronized (_dataLock)
    516508       
    517         if (_log.shouldLog(Log.DEBUG))
     509        if (shouldDebug)
    518510            _log.debug("read(byte[]," + offset + ',' + length + ") read fully; total read: " +_readTotal);
    519511
  • history.txt

    rf12dbba rb5ed39f1  
     12018-07-28 zzz
     2 * Console: Catch ISE in get/setAttribute() (ticket #1529)
     3 * Streaming: Throw exception on read timeout (ticket #2292)
     4
    152018-07-27 zzz
    26 * Console: Split netdb output into pages
  • router/java/src/net/i2p/router/RouterVersion.java

    rf12dbba rb5ed39f1  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 18;
     21    public final static long BUILD = 19;
    2222
    2323    /** for example "-test" */
Note: See TracChangeset for help on using the changeset viewer.