mirror of
https://github.com/i2p/i2p.i2p.git
synced 2024-12-06 19:27:00 +01:00
* I2CP: Limit router/client queue sizes and queue wait times
This commit is contained in:
@@ -52,6 +52,8 @@ class ClientManager {
|
||||
/** SSL interface (only) @since 0.8.3 */
|
||||
private static final String PROP_ENABLE_SSL = "i2cp.SSL";
|
||||
|
||||
private static final int INTERNAL_QUEUE_SIZE = 256;
|
||||
|
||||
public ClientManager(RouterContext context, int port) {
|
||||
_ctx = context;
|
||||
_log = context.logManager().getLog(ClientManager.class);
|
||||
@@ -125,9 +127,8 @@ class ClientManager {
|
||||
public I2CPMessageQueue internalConnect() throws I2PSessionException {
|
||||
if (!_isStarted)
|
||||
throw new I2PSessionException("Router client manager is shut down");
|
||||
// for now we make these unlimited size
|
||||
LinkedBlockingQueue<I2CPMessage> in = new LinkedBlockingQueue();
|
||||
LinkedBlockingQueue<I2CPMessage> out = new LinkedBlockingQueue();
|
||||
LinkedBlockingQueue<I2CPMessage> in = new LinkedBlockingQueue(INTERNAL_QUEUE_SIZE);
|
||||
LinkedBlockingQueue<I2CPMessage> out = new LinkedBlockingQueue(INTERNAL_QUEUE_SIZE);
|
||||
I2CPMessageQueue myQueue = new I2CPMessageQueueImpl(in, out);
|
||||
I2CPMessageQueue hisQueue = new I2CPMessageQueueImpl(out, in);
|
||||
ClientConnectionRunner runner = new QueuedClientConnectionRunner(_ctx, this, myQueue);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.i2p.router.client;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.i2p.data.i2cp.I2CPMessage;
|
||||
import net.i2p.internal.I2CPMessageQueue;
|
||||
@@ -32,6 +33,16 @@ class I2CPMessageQueueImpl extends I2CPMessageQueue {
|
||||
return _out.offer(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message, blocking.
|
||||
* @param timeout how long to wait for space (ms)
|
||||
* @return success (false if no space available or if timed out)
|
||||
* @since 0.9.3
|
||||
*/
|
||||
public boolean offer(I2CPMessage msg, long timeout) throws InterruptedException {
|
||||
return _out.offer(msg, timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive a message, nonblocking
|
||||
* @return message or null if none available
|
||||
|
||||
Reference in New Issue
Block a user