summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2007-01-31 06:19:27 +0000
committerMatthew Newhook <matthew@zeroc.com>2007-01-31 06:19:27 +0000
commit3d64893da7ed76874c93a385f19bded3f65d6ff9 (patch)
treeb0061d5353e776da69b318407d726c3d7e8424e7 /java/src
parentBug 1607. (diff)
downloadice-3d64893da7ed76874c93a385f19bded3f65d6ff9.tar.bz2
ice-3d64893da7ed76874c93a385f19bded3f65d6ff9.tar.xz
ice-3d64893da7ed76874c93a385f19bded3f65d6ff9.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1690
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/ConnectionI.java57
-rw-r--r--java/src/IceInternal/TcpTransceiver.java9
-rw-r--r--java/src/IceInternal/Transceiver.java1
-rw-r--r--java/src/IceInternal/UdpTransceiver.java14
4 files changed, 61 insertions, 20 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java
index 88d49113a31..4d55cb3a05b 100644
--- a/java/src/Ice/ConnectionI.java
+++ b/java/src/Ice/ConnectionI.java
@@ -857,28 +857,45 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
//
_batchStream.swap(os);
- if(_batchAutoFlush && _batchStream.size() > _instance.messageSizeMax())
+ if(_batchAutoFlush)
{
- //
- // Throw memory limit exception if the first message added causes us to
- // go over limit. Otherwise put aside the marshalled message that caused
- // limit to be exceeded and rollback stream to the marker.
- //
- if(_batchRequestNum == 0)
- {
- resetBatch(true);
- throw new MemoryLimitException();
- }
+ synchronized(_sendMutex)
+ {
+ if(_transceiver == null)
+ {
+ assert(_exception != null);
+ throw _exception; // The exception is immutable at this point.
+ }
+ //
+ // Throw memory limit exception if the first
+ // message added causes us to go over
+ // limit. Otherwise put aside the marshalled
+ // message that caused limit to be exceeded and
+ // rollback stream to the marker.
+ try
+ {
+ _transceiver.checkSendSize(_batchStream, _instance.messageSizeMax());
+ }
+ catch(Ice.LocalException ex)
+ {
+ if(_batchRequestNum == 0)
+ {
+ resetBatch(true);
+ throw ex;
+ }
- lastRequest = new byte[_batchStream.size() - _batchMarker];
- java.nio.ByteBuffer buffer = _batchStream.prepareRead();
- buffer.position(_batchMarker);
- buffer.get(lastRequest);
- _batchStream.resize(_batchMarker, false);
- autoflush = true;
- }
- else
- {
+ lastRequest = new byte[_batchStream.size() - _batchMarker];
+ java.nio.ByteBuffer buffer = _batchStream.prepareRead();
+ buffer.position(_batchMarker);
+ buffer.get(lastRequest);
+ _batchStream.resize(_batchMarker, false);
+ autoflush = true;
+ }
+ }
+ }
+
+ if(!autoflush)
+ {
//
// Increment the number of requests in the batch.
//
diff --git a/java/src/IceInternal/TcpTransceiver.java b/java/src/IceInternal/TcpTransceiver.java
index 2bda8a1cdf7..b5537689b71 100644
--- a/java/src/IceInternal/TcpTransceiver.java
+++ b/java/src/IceInternal/TcpTransceiver.java
@@ -324,6 +324,15 @@ final class TcpTransceiver implements Transceiver
return _desc;
}
+ public void
+ checkSendSize(BasicStream stream, int messageSizeMax)
+ {
+ if(stream.size() > messageSizeMax)
+ {
+ throw new Ice.MemoryLimitException();
+ }
+ }
+
//
// Only for use by TcpConnector, TcpAcceptor
//
diff --git a/java/src/IceInternal/Transceiver.java b/java/src/IceInternal/Transceiver.java
index f38730c3767..e04eac5689b 100644
--- a/java/src/IceInternal/Transceiver.java
+++ b/java/src/IceInternal/Transceiver.java
@@ -30,4 +30,5 @@ public interface Transceiver
boolean read(BasicStream stream, int timeout);
String type();
String toString();
+ void checkSendSize(BasicStream stream, int messageSizeMax);
}
diff --git a/java/src/IceInternal/UdpTransceiver.java b/java/src/IceInternal/UdpTransceiver.java
index cc0a4ea8359..2dc4c50adce 100644
--- a/java/src/IceInternal/UdpTransceiver.java
+++ b/java/src/IceInternal/UdpTransceiver.java
@@ -268,6 +268,20 @@ final class UdpTransceiver implements Transceiver
return Network.fdToString(_fd);
}
+ public void
+ checkSendSize(BasicStream stream, int messageSizeMax)
+ {
+ if(stream.size() > messageSizeMax)
+ {
+ throw new Ice.MemoryLimitException();
+ }
+ final int packetSize = java.lang.Math.min(_maxPacketSize, _sndSize - _udpOverhead);
+ if(packetSize < stream.size())
+ {
+ throw new Ice.DatagramLimitException();
+ }
+ }
+
public final boolean
equivalent(String host, int port)
{