minor changes

This commit is contained in:
dev
2011-02-17 10:45:35 +00:00
parent b2433d0e50
commit 84990d9d43
3 changed files with 24 additions and 14 deletions

View File

@@ -30,10 +30,10 @@ public final class I2PDatagramDissector {
private static Log _log = new Log(I2PDatagramDissector.class);
private static int DGRAM_BUFSIZE = 32768;
private static final int DGRAM_BUFSIZE = 32768;
private DSAEngine dsaEng = DSAEngine.getInstance();
private SHA256Generator hashGen = SHA256Generator.getInstance();
private final DSAEngine dsaEng = DSAEngine.getInstance();
private final SHA256Generator hashGen = SHA256Generator.getInstance();
private Hash rxHash = null;
@@ -41,7 +41,7 @@ public final class I2PDatagramDissector {
private Destination rxDest;
private byte[] rxPayload = new byte[DGRAM_BUFSIZE];
private final byte[] rxPayload = new byte[DGRAM_BUFSIZE];
private int rxPayloadLen = 0;
@@ -189,8 +189,7 @@ public final class I2PDatagramDissector {
if(this.valid)
return;
if (rxSign == null || rxSign.getData() == null ||
rxDest == null || rxDest.getSigningPublicKey() == null)
if (rxSign == null || rxSign.getData() == null || rxDest == null || rxDest.getSigningPublicKey() == null)
throw new I2PInvalidDatagramException("Datagram not yet read");
// now validate

View File

@@ -28,15 +28,15 @@ public final class I2PDatagramMaker {
private static Log _log = new Log(I2PDatagramMaker.class);
private static int DGRAM_BUFSIZE = 32768;
private static final int DGRAM_BUFSIZE = 32768;
private SHA256Generator hashGen = SHA256Generator.getInstance();
private DSAEngine dsaEng = DSAEngine.getInstance();
private final SHA256Generator hashGen = SHA256Generator.getInstance();
private final DSAEngine dsaEng = DSAEngine.getInstance();
private SigningPrivateKey sxPrivKey = null;
private byte[] sxDestBytes = null;
private ByteArrayOutputStream sxDGram = new ByteArrayOutputStream(DGRAM_BUFSIZE);
private final ByteArrayOutputStream sxDGram = new ByteArrayOutputStream(DGRAM_BUFSIZE);
/**
* Construct a new I2PDatagramMaker that will be able to create I2P

View File

@@ -5,7 +5,7 @@ import net.i2p.data.i2cp.I2CPMessageReader;
import net.i2p.util.I2PThread;
/**
* Get messages off an In-JVM queue, zero-copy
* Get messages off an In-JVM queue, zero-copy.
*
* @author zzz
* @since 0.8.3
@@ -13,6 +13,9 @@ import net.i2p.util.I2PThread;
public class QueuedI2CPMessageReader extends I2CPMessageReader {
private final I2CPMessageQueue in;
/**
* Creates a new instance of this QueuedMessageReader and spawns a pumper thread.
*/
public QueuedI2CPMessageReader(I2CPMessageQueue in, I2CPMessageEventListener lsnr) {
super(lsnr);
this.in = in;
@@ -25,13 +28,19 @@ public class QueuedI2CPMessageReader extends I2CPMessageReader {
public QueuedI2CPMessageReaderRunner() {
super();
}
/**
* Shuts the pumper down.
*/
@Override
public void cancelRunner() {
super.cancelRunner();
_readerThread.interrupt();
}
/**
* Pumps messages from the incoming message queue to the listener.
*/
@Override
public void run() {
while (_stayAlive) {
@@ -46,7 +55,9 @@ public class QueuedI2CPMessageReader extends I2CPMessageReader {
} else {
_listener.messageReceived(QueuedI2CPMessageReader.this, msg);
}
} catch (InterruptedException ie) {}
} catch (InterruptedException ie) {
// hint that we probably should check the continue running flag
}
}
// ??? unused
if (_stayAlive && !_doRun) {