summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/BasicStream.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-03-24 11:45:18 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-03-24 11:45:18 +0100
commit06a08ecf28e205277336a97a6173db7ccbed1adc (patch)
treea369a5044a63f8cdba9e7c0a461e24ae344486b4 /cpp/src/Ice/BasicStream.cpp
parentMerge branch 'R3_3_branch' (diff)
parentBug 3924: slice2py missing from VC60 installer (diff)
downloadice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.bz2
ice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.xz
ice-06a08ecf28e205277336a97a6173db7ccbed1adc.zip
Merge commit 'origin/R3_3_branch'
Conflicts: CHANGES cpp/demo/Freeze/backup/.depend cpp/demo/Freeze/bench/.depend cpp/demo/Freeze/casino/.depend cpp/demo/Freeze/customEvictor/.depend cpp/demo/Freeze/library/.depend cpp/demo/Freeze/phonebook/.depend cpp/demo/Freeze/transform/.depend cpp/demo/Glacier2/callback/.depend cpp/demo/Glacier2/chat/.depend cpp/demo/Ice/async/.depend cpp/demo/Ice/bidir/.depend cpp/demo/Ice/callback/.depend cpp/demo/Ice/converter/.depend cpp/demo/Ice/hello/.depend cpp/demo/Ice/invoke/.depend cpp/demo/Ice/latency/.depend cpp/demo/Ice/minimal/.depend cpp/demo/Ice/multicast/.depend cpp/demo/Ice/nested/.depend cpp/demo/Ice/nrvo/.depend cpp/demo/Ice/session/.depend cpp/demo/Ice/throughput/.depend cpp/demo/Ice/value/.depend cpp/demo/IceBox/hello/.depend cpp/demo/IceGrid/allocate/.depend cpp/demo/IceGrid/icebox/.depend cpp/demo/IceGrid/replication/.depend cpp/demo/IceGrid/sessionActivation/.depend cpp/demo/IceGrid/simple/.depend cpp/demo/IceStorm/clock/.depend cpp/demo/IceStorm/counter/.depend cpp/demo/IceStorm/replicated/.depend cpp/demo/IceStorm/replicated2/.depend cpp/demo/book/freeze_filesystem/.depend cpp/demo/book/lifecycle/.depend cpp/demo/book/printer/.depend cpp/demo/book/simple_filesystem/.depend cpp/src/Freeze/.depend cpp/src/FreezeScript/.depend cpp/src/Ice/.depend cpp/src/Ice/UdpTransceiver.cpp cpp/src/Ice/UdpTransceiver.h cpp/src/IceBox/.depend cpp/src/IceGrid/.depend cpp/src/IceGridLib/.depend cpp/src/IcePatch2/.depend cpp/src/IceStorm/.depend cpp/src/slice2freeze/.depend cpp/test/Freeze/complex/.depend cpp/test/Freeze/dbmap/.depend cpp/test/Freeze/evictor/.depend cpp/test/Freeze/oldevictor/.depend cpp/test/FreezeScript/dbmap/.depend cpp/test/FreezeScript/evictor/.depend cpp/test/Glacier2/attack/.depend cpp/test/Glacier2/dynamicFiltering/.depend cpp/test/Glacier2/router/.depend cpp/test/Glacier2/sessionControl/.depend cpp/test/Glacier2/ssl/.depend cpp/test/Glacier2/staticFiltering/.depend cpp/test/Ice/adapterDeactivation/.depend cpp/test/Ice/background/.depend cpp/test/Ice/binding/.depend cpp/test/Ice/checksum/.depend cpp/test/Ice/checksum/server/.depend cpp/test/Ice/custom/.depend cpp/test/Ice/exceptions/.depend cpp/test/Ice/facets/.depend cpp/test/Ice/faultTolerance/.depend cpp/test/Ice/gc/.depend cpp/test/Ice/hold/.depend cpp/test/Ice/inheritance/.depend cpp/test/Ice/interceptor/.depend cpp/test/Ice/location/.depend cpp/test/Ice/objects/.depend cpp/test/Ice/operations/.depend cpp/test/Ice/proxy/.depend cpp/test/Ice/retry/.depend cpp/test/Ice/servantLocator/.depend cpp/test/Ice/slicing/exceptions/.depend cpp/test/Ice/slicing/objects/.depend cpp/test/Ice/stream/.depend cpp/test/Ice/stringConverter/.depend cpp/test/Ice/timeout/.depend cpp/test/Ice/udp/.depend cpp/test/IceBox/configuration/.depend cpp/test/IceGrid/activation/.depend cpp/test/IceGrid/allocation/.depend cpp/test/IceGrid/deployer/.depend cpp/test/IceGrid/distribution/.depend cpp/test/IceGrid/replicaGroup/.depend cpp/test/IceGrid/replication/.depend cpp/test/IceGrid/session/.depend cpp/test/IceGrid/simple/.depend cpp/test/IceGrid/update/.depend cpp/test/IceSSL/configuration/.depend cpp/test/IceStorm/federation/.depend cpp/test/IceStorm/federation2/.depend cpp/test/IceStorm/rep1/.depend cpp/test/IceStorm/repgrid/.depend cpp/test/IceStorm/repstress/.depend cpp/test/IceStorm/single/.depend cpp/test/IceStorm/stress/.depend cpp/test/Slice/keyword/.depend cs/src/Ice/Instance.cs cs/src/IceSSL/ConnectorI.cs java/demo/book/simple_filesystem/Filesystem/DirectoryI.java java/demo/book/simple_filesystem/Filesystem/FileI.java java/src/IceInternal/TcpConnector.java java/src/IceSSL/ConnectorI.java py/modules/IcePy/.depend rb/src/IceRuby/.depend
Diffstat (limited to 'cpp/src/Ice/BasicStream.cpp')
-rw-r--r--cpp/src/Ice/BasicStream.cpp113
1 files changed, 91 insertions, 22 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index c5c53947751..e1a475f8ee1 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -291,6 +291,26 @@ IceInternal::BasicStream::ReadEncaps::swap(ReadEncaps& other)
std::swap(previous, other.previous);
}
+void
+IceInternal::BasicStream::endWriteEncapsChecked()
+{
+ if(!_currentWriteEncaps)
+ {
+ throw EncapsulationException(__FILE__, __LINE__, "not in an encapsulation");
+ }
+ endWriteEncaps();
+}
+
+void
+IceInternal::BasicStream::endReadEncapsChecked()
+{
+ if(!_currentReadEncaps)
+ {
+ throw EncapsulationException(__FILE__, __LINE__, "not in an encapsulation");
+ }
+ endReadEncaps();
+}
+
Int
IceInternal::BasicStream::getReadEncapsSize()
{
@@ -377,6 +397,14 @@ IceInternal::BasicStream::skipSlice()
void
IceInternal::BasicStream::writeTypeId(const string& id)
{
+ if(!_currentWriteEncaps || !_currentWriteEncaps->typeIdMap)
+ {
+ //
+ // write(ObjectPtr) must be called first.
+ //
+ throw MarshalException(__FILE__, __LINE__, "type ids require an encapsulation");
+ }
+
TypeIdWriteMap::const_iterator k = _currentWriteEncaps->typeIdMap->find(id);
if(k != _currentWriteEncaps->typeIdMap->end())
{
@@ -394,6 +422,14 @@ IceInternal::BasicStream::writeTypeId(const string& id)
void
IceInternal::BasicStream::readTypeId(string& id)
{
+ if(!_currentReadEncaps || !_currentReadEncaps->typeIdMap)
+ {
+ //
+ // read(PatchFunc, void*) must be called first.
+ //
+ throw MarshalException(__FILE__, __LINE__, "type ids require an encapsulation");
+ }
+
bool isIndex;
read(isIndex);
if(isIndex)
@@ -1743,34 +1779,42 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
Int index;
read(index);
- if(index == 0)
+ if(patchAddr)
{
- patchFunc(patchAddr, v); // Null Ptr.
- return;
- }
+ if(index == 0)
+ {
+ // Calling the patch function for null instances is necessary for correct functioning of Ice for
+ // Python and Ruby.
+ patchFunc(patchAddr, v); // Null Ptr.
+ return;
+ }
- if(index < 0 && patchAddr)
- {
- PatchMap::iterator p = _currentReadEncaps->patchMap->find(-index);
- if(p == _currentReadEncaps->patchMap->end())
+ if(index < 0)
{
+ PatchMap::iterator p = _currentReadEncaps->patchMap->find(-index);
+ if(p == _currentReadEncaps->patchMap->end())
+ {
+ //
+ // We have no outstanding instances to be patched for this
+ // index, so make a new entry in the patch map.
+ //
+ p = _currentReadEncaps->patchMap->insert(make_pair(-index, PatchList())).first;
+ }
//
- // We have no outstanding instances to be patched for this
- // index, so make a new entry in the patch map.
+ // Append a patch entry for this instance.
//
- p = _currentReadEncaps->patchMap->insert(make_pair(-index, PatchList())).first;
+ PatchEntry e;
+ e.patchFunc = patchFunc;
+ e.patchAddr = patchAddr;
+ p->second.push_back(e);
+ patchPointers(-index, _currentReadEncaps->unmarshaledMap->end(), p);
+ return;
}
- //
- // Append a patch entry for this instance.
- //
- PatchEntry e;
- e.patchFunc = patchFunc;
- e.patchAddr = patchAddr;
- p->second.push_back(e);
- patchPointers(-index, _currentReadEncaps->unmarshaledMap->end(), p);
- return;
}
- assert(index > 0);
+ if(index <= 0)
+ {
+ throw MarshalException(__FILE__, __LINE__, "Invalid class instance index");
+ }
string mostDerivedId;
readTypeId(mostDerivedId);
@@ -1896,6 +1940,8 @@ IceInternal::BasicStream::throwException()
string id;
read(id, false);
+ const string origId = id;
+
for(;;)
{
//
@@ -1938,8 +1984,22 @@ IceInternal::BasicStream::throwException()
{
traceSlicing("exception", id, _slicingCat, _instance->initializationData().logger);
}
+
skipSlice(); // Slice off what we don't understand.
- read(id, false); // Read type id for next slice.
+
+ try
+ {
+ read(id, false); // Read type id for next slice.
+ }
+ catch(UnmarshalOutOfBoundsException& ex)
+ {
+ //
+ // When read() raises this exception it means we've seen the last slice,
+ // so we set the reason member to a more helpful message.
+ //
+ ex.reason = "unknown exception type `" + origId + "'";
+ throw;
+ }
}
}
@@ -2004,6 +2064,15 @@ IceInternal::BasicStream::readPendingObjects()
}
while(num);
+ if(_currentReadEncaps && _currentReadEncaps->patchMap && _currentReadEncaps->patchMap->size() != 0)
+ {
+ //
+ // If any entries remain in the patch map, the sender has sent an index for an object, but failed
+ // to supply the object.
+ //
+ throw MarshalException(__FILE__, __LINE__, "Index for class received, but no instance");
+ }
+
//
// Iterate over the object list and invoke ice_postUnmarshal on
// each object. We must do this after all objects have been