forked from I2P_Developers/i2p.i2p
* i2ptunnel, I2CP, EepGet: Buffer socket input streams (ticket #666)
* I2PSessionImpl: One more volatile (ticket #659)
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.i2p.i2ptunnel;
|
package net.i2p.i2ptunnel;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -219,6 +220,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
// shadows _log in super()
|
// shadows _log in super()
|
||||||
private final Log _log;
|
private final Log _log;
|
||||||
|
|
||||||
|
private static final int BUF_SIZE = 16*1024;
|
||||||
|
|
||||||
public CompressedRequestor(Socket webserver, I2PSocket browser, String headers, I2PAppContext ctx, Log log) {
|
public CompressedRequestor(Socket webserver, I2PSocket browser, String headers, I2PAppContext ctx, Log log) {
|
||||||
_webserver = webserver;
|
_webserver = webserver;
|
||||||
_browser = browser;
|
_browser = browser;
|
||||||
@ -259,7 +262,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
// at java.lang.Thread.run(Thread.java:619)
|
// at java.lang.Thread.run(Thread.java:619)
|
||||||
// at net.i2p.util.I2PThread.run(I2PThread.java:71)
|
// at net.i2p.util.I2PThread.run(I2PThread.java:71)
|
||||||
try {
|
try {
|
||||||
serverin = _webserver.getInputStream();
|
serverin = new BufferedInputStream(_webserver.getInputStream(), BUF_SIZE);
|
||||||
} catch (NullPointerException npe) {
|
} catch (NullPointerException npe) {
|
||||||
throw new IOException("getInputStream NPE");
|
throw new IOException("getInputStream NPE");
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.i2p.i2ptunnel;
|
package net.i2p.i2ptunnel;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
@ -17,6 +18,7 @@ import net.i2p.data.ByteArray;
|
|||||||
import net.i2p.util.ByteCache;
|
import net.i2p.util.ByteCache;
|
||||||
import net.i2p.util.Clock;
|
import net.i2p.util.Clock;
|
||||||
import net.i2p.util.I2PAppThread;
|
import net.i2p.util.I2PAppThread;
|
||||||
|
import net.i2p.util.InternalSocket;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErrorListener {
|
public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErrorListener {
|
||||||
@ -167,6 +169,8 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
|
|||||||
_log.debug("Initial data " + (initialI2PData != null ? initialI2PData.length : 0)
|
_log.debug("Initial data " + (initialI2PData != null ? initialI2PData.length : 0)
|
||||||
+ " written to I2P, " + (initialSocketData != null ? initialSocketData.length : 0)
|
+ " written to I2P, " + (initialSocketData != null ? initialSocketData.length : 0)
|
||||||
+ " written to the socket, starting forwarders");
|
+ " written to the socket, starting forwarders");
|
||||||
|
if (!(s instanceof InternalSocket))
|
||||||
|
in = new BufferedInputStream(in, 2*NETWORK_BUFFER_SIZE);
|
||||||
Thread t1 = new StreamForwarder(in, i2pout, true);
|
Thread t1 = new StreamForwarder(in, i2pout, true);
|
||||||
Thread t2 = new StreamForwarder(i2pin, out, false);
|
Thread t2 = new StreamForwarder(i2pin, out, false);
|
||||||
synchronized (finishLock) {
|
synchronized (finishLock) {
|
||||||
|
@ -9,6 +9,7 @@ package net.i2p.client;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -116,7 +117,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
protected volatile boolean _closing;
|
protected volatile boolean _closing;
|
||||||
|
|
||||||
/** have we received the current date from the router yet? */
|
/** have we received the current date from the router yet? */
|
||||||
private boolean _dateReceived;
|
private volatile boolean _dateReceived;
|
||||||
/** lock that we wait upon, that the SetDateMessageHandler notifies */
|
/** lock that we wait upon, that the SetDateMessageHandler notifies */
|
||||||
private final Object _dateReceivedLock = new Object();
|
private final Object _dateReceivedLock = new Object();
|
||||||
|
|
||||||
@ -155,6 +156,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
|
|
||||||
public static final int LISTEN_PORT = 7654;
|
public static final int LISTEN_PORT = 7654;
|
||||||
|
|
||||||
|
private static final int BUF_SIZE = 32*1024;
|
||||||
|
|
||||||
/** for extension */
|
/** for extension */
|
||||||
protected I2PSessionImpl(I2PAppContext context, Properties options) {
|
protected I2PSessionImpl(I2PAppContext context, Properties options) {
|
||||||
_context = context;
|
_context = context;
|
||||||
@ -353,7 +356,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
_out.write(I2PClient.PROTOCOL_BYTE);
|
_out.write(I2PClient.PROTOCOL_BYTE);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
_writer = new ClientWriterRunner(_out, this);
|
_writer = new ClientWriterRunner(_out, this);
|
||||||
InputStream in = _socket.getInputStream();
|
InputStream in = new BufferedInputStream(_socket.getInputStream(), BUF_SIZE);
|
||||||
_reader = new I2CPMessageReader(in, this);
|
_reader = new I2CPMessageReader(in, this);
|
||||||
}
|
}
|
||||||
Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getPrefix(), true);
|
Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getPrefix(), true);
|
||||||
|
@ -5,6 +5,7 @@ package net.i2p.client;
|
|||||||
* with no warranty of any kind, either expressed or implied.
|
* with no warranty of any kind, either expressed or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
@ -28,6 +29,8 @@ import net.i2p.internal.QueuedI2CPMessageReader;
|
|||||||
*/
|
*/
|
||||||
class I2PSimpleSession extends I2PSessionImpl2 {
|
class I2PSimpleSession extends I2PSessionImpl2 {
|
||||||
|
|
||||||
|
private static final int BUF_SIZE = 1024;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new session for doing naming and bandwidth queries only. Do not create a destination.
|
* Create a new session for doing naming and bandwidth queries only. Do not create a destination.
|
||||||
*
|
*
|
||||||
@ -68,7 +71,7 @@ class I2PSimpleSession extends I2PSessionImpl2 {
|
|||||||
_out.write(I2PClient.PROTOCOL_BYTE);
|
_out.write(I2PClient.PROTOCOL_BYTE);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
_writer = new ClientWriterRunner(_out, this);
|
_writer = new ClientWriterRunner(_out, this);
|
||||||
InputStream in = _socket.getInputStream();
|
InputStream in = new BufferedInputStream(_socket.getInputStream(), BUF_SIZE);
|
||||||
_reader = new I2CPMessageReader(in, this);
|
_reader = new I2CPMessageReader(in, this);
|
||||||
}
|
}
|
||||||
// we do not receive payload messages, so we do not need an AvailabilityNotifier
|
// we do not receive payload messages, so we do not need an AvailabilityNotifier
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.util;
|
package net.i2p.util;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -1057,6 +1058,8 @@ public class EepGet {
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
_proxyIn = _proxy.getInputStream();
|
_proxyIn = _proxy.getInputStream();
|
||||||
|
if (!(_proxy instanceof InternalSocket))
|
||||||
|
_proxyIn = new BufferedInputStream(_proxyIn);
|
||||||
_proxyOut = _proxy.getOutputStream();
|
_proxyOut = _proxy.getOutputStream();
|
||||||
|
|
||||||
if (timeout != null)
|
if (timeout != null)
|
||||||
|
@ -27,7 +27,7 @@ public class InternalServerSocket extends ServerSocket {
|
|||||||
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap(4);
|
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap(4);
|
||||||
private final BlockingQueue<InternalSocket> _acceptQueue;
|
private final BlockingQueue<InternalSocket> _acceptQueue;
|
||||||
private final Integer _port;
|
private final Integer _port;
|
||||||
private boolean _running;
|
private volatile boolean _running;
|
||||||
//private static Log _log = I2PAppContext.getGlobalContext().logManager().getLog(InternalServerSocket.class);
|
//private static Log _log = I2PAppContext.getGlobalContext().logManager().getLog(InternalServerSocket.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,6 +37,7 @@ package net.i2p.util;
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -676,6 +677,8 @@ public class SSLEepGet extends EepGet {
|
|||||||
throw sslhe;
|
throw sslhe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_proxyIn = new BufferedInputStream(_proxyIn);
|
||||||
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Request flushed");
|
_log.debug("Request flushed");
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ package net.i2p.router.client;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -96,6 +97,8 @@ class ClientConnectionRunner {
|
|||||||
// e.g. on local access
|
// e.g. on local access
|
||||||
private static final int MAX_MESSAGE_ID = 0x4000000;
|
private static final int MAX_MESSAGE_ID = 0x4000000;
|
||||||
|
|
||||||
|
private static final int BUF_SIZE = 32*1024;
|
||||||
|
|
||||||
/** @since 0.9.2 */
|
/** @since 0.9.2 */
|
||||||
private static final String PROP_TAGS = "crypto.tagsToSend";
|
private static final String PROP_TAGS = "crypto.tagsToSend";
|
||||||
private static final String PROP_THRESH = "crypto.lowTagThreshold";
|
private static final String PROP_THRESH = "crypto.lowTagThreshold";
|
||||||
@ -124,7 +127,8 @@ class ClientConnectionRunner {
|
|||||||
*/
|
*/
|
||||||
public void startRunning() {
|
public void startRunning() {
|
||||||
try {
|
try {
|
||||||
_reader = new I2CPMessageReader(_socket.getInputStream(), new ClientMessageEventListener(_context, this, true));
|
_reader = new I2CPMessageReader(new BufferedInputStream(_socket.getInputStream(), BUF_SIZE),
|
||||||
|
new ClientMessageEventListener(_context, this, true));
|
||||||
_writer = new ClientWriterRunner(_context, this);
|
_writer = new ClientWriterRunner(_context, this);
|
||||||
I2PThread t = new I2PThread(_writer);
|
I2PThread t = new I2PThread(_writer);
|
||||||
t.setName("I2CP Writer " + ++__id);
|
t.setName("I2CP Writer " + ++__id);
|
||||||
|
Reference in New Issue
Block a user