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:
@ -9,6 +9,7 @@ package net.i2p.client;
|
||||
*
|
||||
*/
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -116,7 +117,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
protected volatile boolean _closing;
|
||||
|
||||
/** 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 */
|
||||
private final Object _dateReceivedLock = new Object();
|
||||
|
||||
@ -154,6 +155,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
}
|
||||
|
||||
public static final int LISTEN_PORT = 7654;
|
||||
|
||||
private static final int BUF_SIZE = 32*1024;
|
||||
|
||||
/** for extension */
|
||||
protected I2PSessionImpl(I2PAppContext context, Properties options) {
|
||||
@ -353,7 +356,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
_out.write(I2PClient.PROTOCOL_BYTE);
|
||||
_out.flush();
|
||||
_writer = new ClientWriterRunner(_out, this);
|
||||
InputStream in = _socket.getInputStream();
|
||||
InputStream in = new BufferedInputStream(_socket.getInputStream(), BUF_SIZE);
|
||||
_reader = new I2CPMessageReader(in, this);
|
||||
}
|
||||
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.
|
||||
*/
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
@ -28,6 +29,8 @@ import net.i2p.internal.QueuedI2CPMessageReader;
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -68,7 +71,7 @@ class I2PSimpleSession extends I2PSessionImpl2 {
|
||||
_out.write(I2PClient.PROTOCOL_BYTE);
|
||||
_out.flush();
|
||||
_writer = new ClientWriterRunner(_out, this);
|
||||
InputStream in = _socket.getInputStream();
|
||||
InputStream in = new BufferedInputStream(_socket.getInputStream(), BUF_SIZE);
|
||||
_reader = new I2CPMessageReader(in, this);
|
||||
}
|
||||
// we do not receive payload messages, so we do not need an AvailabilityNotifier
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.i2p.util;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -1057,6 +1058,8 @@ public class EepGet {
|
||||
//}
|
||||
}
|
||||
_proxyIn = _proxy.getInputStream();
|
||||
if (!(_proxy instanceof InternalSocket))
|
||||
_proxyIn = new BufferedInputStream(_proxyIn);
|
||||
_proxyOut = _proxy.getOutputStream();
|
||||
|
||||
if (timeout != null)
|
||||
|
@ -27,7 +27,7 @@ public class InternalServerSocket extends ServerSocket {
|
||||
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap(4);
|
||||
private final BlockingQueue<InternalSocket> _acceptQueue;
|
||||
private final Integer _port;
|
||||
private boolean _running;
|
||||
private volatile boolean _running;
|
||||
//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.
|
||||
*/
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -675,6 +676,8 @@ public class SSLEepGet extends EepGet {
|
||||
// this is an IOE
|
||||
throw sslhe;
|
||||
}
|
||||
|
||||
_proxyIn = new BufferedInputStream(_proxyIn);
|
||||
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Request flushed");
|
||||
|
Reference in New Issue
Block a user