Changeset 18531f0


Ignore:
Timestamp:
Jul 5, 2013 12:43:58 PM (7 years ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
ba0e58e6
Parents:
93df048
Message:

Log close() loops

Location:
apps/streaming/java/src/net/i2p/client/streaming
Files:
1 added
2 edited

Legend:

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

    r93df048 r18531f0  
    55import java.io.OutputStream;
    66import java.nio.channels.SelectableChannel;
     7import java.util.concurrent.atomic.AtomicBoolean;
    78
     9import net.i2p.I2PAppContext;
    810import net.i2p.client.I2PSession;
    911import net.i2p.data.Destination;
     12import net.i2p.util.Log;
    1013
    1114/**
     
    1417 */
    1518class I2PSocketFull implements I2PSocket {
    16     private Connection _connection;
    17     private Destination _remotePeer;
    18     private Destination _localPeer;
     19    private final Log log;
     20    private volatile Connection _connection;
     21    private final Destination _remotePeer;
     22    private final Destination _localPeer;
    1923    private volatile MessageChannel _channel;
     24    private final AtomicBoolean _closed = new AtomicBoolean(false);
    2025   
    21     public I2PSocketFull(Connection con) {
     26    public I2PSocketFull(Connection con, I2PAppContext context) {
     27        log = context.logManager().getLog(I2PSocketFull.class);
    2228        _connection = con;
    2329        if (con != null) {
    2430            _remotePeer = con.getRemotePeer();
    2531            _localPeer = con.getSession().getMyDestination();
    26         }
     32        } else
     33            _remotePeer = _localPeer = null;
    2734    }
    2835   
    2936    public void close() throws IOException {
     37        if (!_closed.compareAndSet(false,true)) {
     38            // log a trace to find out why
     39            LogUtil.logCloseLoop(log, "I2PSocket",_localPeer,"-->",_remotePeer,_connection);
     40            return;
     41        }
    3042        Connection c = _connection;
    3143        if (c == null) return;
  • apps/streaming/java/src/net/i2p/client/streaming/I2PSocketManagerFull.java

    r93df048 r18531f0  
    317317        if (!_isDestroyed.compareAndSet(false,true)) {
    318318            // shouldn't happen, log a stack trace to find out why it happened
    319             if (_log.shouldLog(Log.WARN)) {
    320                 String log = "over-destroying manager "+getName();
    321                 _log.log(Log.WARN,log,new Exception("check stack trace"));
    322             }
     319            LogUtil.logCloseLoop(_log, "I2PSocketManager", getName());
    323320            return;
    324321        }
Note: See TracChangeset for help on using the changeset viewer.