Changeset d078ed3


Ignore:
Timestamp:
Nov 6, 2009 7:16:23 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
9203663
Parents:
7c36c0c
Message:

move init, add config

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

Legend:

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

    r7c36c0c rd078ed3  
    9494                      + "\noriginal properties: " + opts);
    9595        }
     96        debugInit(context);
    9697    }
    9798
     
    270271        _connectionManager.getMessageHandler().removeDisconnectListener(lsnr);
    271272    }
     273
     274    private static final Object _pcapInitLock = new Object();
     275    private static boolean _pcapInitialized;
     276    static PcapWriter pcapWriter;
     277    static final String PROP_PCAP = "i2p.streaming.pcap";
     278    private static final String PCAP_FILE = "streaming.pcap";
     279
     280    private static void debugInit(I2PAppContext ctx) {
     281        if (!Boolean.valueOf(ctx.getProperty(PROP_PCAP)).booleanValue())
     282            return;
     283        synchronized(_pcapInitLock) {
     284            if (!_pcapInitialized) {
     285                try {
     286                    pcapWriter = new PcapWriter(ctx, PCAP_FILE);
     287                } catch (java.io.IOException ioe) {
     288                     System.err.println("pcap init ioe: " + ioe);
     289                }
     290                _pcapInitialized = true;
     291            }
     292        }
     293    }
    272294}
  • apps/streaming/java/src/net/i2p/client/streaming/PacketLocal.java

    r7c36c0c rd078ed3  
    3030    private volatile boolean _retransmitted;
    3131    private SimpleTimer2.TimedEvent _resendEvent;
    32     private static final Object initLock = new Object();
    33     private static boolean _initialized;
    34     private static PcapWriter _pcapWriter;
    3532   
    3633    public PacketLocal(I2PAppContext ctx, Destination to) {
     
    4744        _nackCount = 0;
    4845        _retransmitted = false;
    49         synchronized(initLock) {
    50             if (!_initialized) {
    51                 initPcap();
    52                 _initialized = true;
    53             }
    54         }
    5546    }
    5647   
     
    256247    public boolean writeSuccessful() { return _ackOn > 0 && _cancelledOn <= 0; }
    257248
    258     static final String PCAP = "foo.pcap";
    259     private void initPcap() {
    260         try {
    261             _pcapWriter = new PcapWriter(_context, PCAP);
    262         } catch (IOException ioe) {
    263            System.err.println("pcap init ioe: " + ioe);
    264         }
    265     }
    266 
    267249    /** Generate a pcap/tcpdump-compatible format,
    268250     *  so we can use standard debugging tools.
    269251     */
    270252    public void logTCPDump(boolean isInbound) {
    271         if (!_log.shouldLog(Log.INFO)) return;
    272         _log.info(toString());
    273         if (_pcapWriter != null) {
     253        if (_log.shouldLog(Log.INFO))
     254            _log.info(toString());
     255        if (I2PSocketManagerFull.pcapWriter != null &&
     256            Boolean.valueOf(_context.getProperty(I2PSocketManagerFull.PROP_PCAP)).booleanValue()) {
    274257            try {
    275                 _pcapWriter.write(this, isInbound);
     258                I2PSocketManagerFull.pcapWriter.write(this, isInbound);
    276259            } catch (IOException ioe) {
    277260               _log.warn("pcap write ioe: " + ioe);
Note: See TracChangeset for help on using the changeset viewer.