summaryrefslogtreecommitdiff
path: root/cpp/src/Ice
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2008-01-09 21:27:15 +0100
committerBenoit Foucher <benoit@zeroc.com>2008-01-09 21:27:15 +0100
commit5b2cdfebdd59ca3f99eb306e0ccf775fc0a81b83 (patch)
tree3414c09ed68bbbda6d446a76c552e065c9e91108 /cpp/src/Ice
parentAdded info on mcpp (diff)
downloadice-5b2cdfebdd59ca3f99eb306e0ccf775fc0a81b83.tar.bz2
ice-5b2cdfebdd59ca3f99eb306e0ccf775fc0a81b83.tar.xz
ice-5b2cdfebdd59ca3f99eb306e0ccf775fc0a81b83.zip
- Fixed bug 1619, part of 2632.
Diffstat (limited to 'cpp/src/Ice')
-rw-r--r--cpp/src/Ice/BasicStream.cpp18
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.cpp1
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.h1
-rw-r--r--cpp/src/Ice/ConnectionRequestHandler.cpp4
-rw-r--r--cpp/src/Ice/ConnectionRequestHandler.h1
-rw-r--r--cpp/src/Ice/Incoming.cpp10
-rw-r--r--cpp/src/Ice/Network.cpp10
-rw-r--r--cpp/src/Ice/Object.cpp43
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp8
-rw-r--r--cpp/src/Ice/Outgoing.cpp27
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp20
-rw-r--r--cpp/src/Ice/Proxy.cpp49
-rw-r--r--cpp/src/Ice/RequestHandler.cpp5
-rw-r--r--cpp/src/Ice/RequestHandler.h1
-rw-r--r--cpp/src/Ice/StreamI.cpp6
-rw-r--r--cpp/src/Ice/StreamI.h1
16 files changed, 130 insertions, 75 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index e636c0d952d..6c710bd5ab5 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -291,18 +291,6 @@ IceInternal::BasicStream::ReadEncaps::swap(ReadEncaps& other)
std::swap(previous, other.previous);
}
-void
-IceInternal::BasicStream::checkReadEncaps()
-{
- assert(_currentReadEncaps);
- Container::size_type start = _currentReadEncaps->start;
- Int sz = _currentReadEncaps->sz;
- if(i != b.begin() + start + sz)
- {
- throw EncapsulationException(__FILE__, __LINE__);
- }
-}
-
Int
IceInternal::BasicStream::getReadEncapsSize()
{
@@ -2017,6 +2005,12 @@ IceInternal::BasicStream::throwUnsupportedEncodingException(const char* file, in
}
void
+IceInternal::BasicStream::throwEncapsulationException(const char* file, int line)
+{
+ throw EncapsulationException(file, line);
+}
+
+void
IceInternal::BasicStream::writeInstance(const ObjectPtr& v, Int index)
{
write(index);
diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp
index 20d326061dc..d334c1b6c3f 100644
--- a/cpp/src/Ice/ConnectRequestHandler.cpp
+++ b/cpp/src/Ice/ConnectRequestHandler.cpp
@@ -79,7 +79,6 @@ ConnectRequestHandler::ConnectRequestHandler(const ReferencePtr& ref,
RequestHandler(ref),
_proxy(proxy),
_delegate(delegate),
- _response(ref->getMode() == Reference::ModeTwoway),
_batchAutoFlush(
ref->getInstance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0),
_initialized(false),
diff --git a/cpp/src/Ice/ConnectRequestHandler.h b/cpp/src/Ice/ConnectRequestHandler.h
index b05a33fdfec..a94505003db 100644
--- a/cpp/src/Ice/ConnectRequestHandler.h
+++ b/cpp/src/Ice/ConnectRequestHandler.h
@@ -71,7 +71,6 @@ private:
Ice::ObjectPrx _proxy;
Handle< ::IceDelegate::Ice::Object> _delegate;
- const bool _response;
const bool _batchAutoFlush;
Ice::ConnectionIPtr _connection;
diff --git a/cpp/src/Ice/ConnectionRequestHandler.cpp b/cpp/src/Ice/ConnectionRequestHandler.cpp
index 736e1cdbc0c..35eb67a6c5a 100644
--- a/cpp/src/Ice/ConnectionRequestHandler.cpp
+++ b/cpp/src/Ice/ConnectionRequestHandler.cpp
@@ -19,8 +19,7 @@ using namespace std;
using namespace IceInternal;
ConnectionRequestHandler::ConnectionRequestHandler(const ReferencePtr& reference, const Ice::ObjectPrx& proxy) :
- RequestHandler(reference),
- _response(reference->getMode() == Reference::ModeTwoway)
+ RequestHandler(reference)
{
_connection = _reference->getConnection(_compress);
RouterInfoPtr ri = reference->getRouterInfo();
@@ -34,7 +33,6 @@ ConnectionRequestHandler::ConnectionRequestHandler(const ReferencePtr& reference
const Ice::ConnectionIPtr& connection,
bool compress) :
RequestHandler(reference),
- _response(reference->getMode() == Reference::ModeTwoway),
_connection(connection),
_compress(compress)
{
diff --git a/cpp/src/Ice/ConnectionRequestHandler.h b/cpp/src/Ice/ConnectionRequestHandler.h
index 785cda3b5b6..68daba81e31 100644
--- a/cpp/src/Ice/ConnectionRequestHandler.h
+++ b/cpp/src/Ice/ConnectionRequestHandler.h
@@ -38,7 +38,6 @@ public:
private:
- const bool _response;
Ice::ConnectionIPtr _connection;
bool _compress;
};
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index d7d4bd253b0..cddef9f98e4 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -296,7 +296,7 @@ IceInternal::Incoming::startOver()
//
// That's the first startOver, so almost nothing to do
//
- _inParamPos = _is.i - 6; // 6 bytes for the start of the encaps
+ _inParamPos = _is.i;
}
else
{
@@ -305,9 +305,7 @@ IceInternal::Incoming::startOver()
//
// Let's rewind _is and clean-up _os
//
- _is.endReadEncaps();
_is.i = _inParamPos;
- _is.startReadEncaps();
if(_response)
{
@@ -384,8 +382,6 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_current.ctx.insert(_current.ctx.end(), pr);
}
- _is.startReadEncaps();
-
if(_response)
{
assert(_os.b.size() == headerSize + 4); // Reply status position.
@@ -508,13 +504,11 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
}
catch(const std::exception& ex)
{
- _is.endReadEncaps();
__handleException(ex);
return;
}
catch(...)
{
- _is.endReadEncaps();
__handleException();
return;
}
@@ -524,8 +518,6 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
// in the code below are considered fatal, and must propagate to
// the caller of this operation.
//
-
- _is.endReadEncaps();
//
// DispatchAsync is "pseudo dispatch status", used internally only
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index 002ea18b780..70940b2e7c3 100644
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -878,6 +878,11 @@ IceInternal::doBind(SOCKET fd, struct sockaddr_storage& addr)
{
size = sizeof(sockaddr_in6);
}
+ else
+ {
+ assert(false);
+ size = 0; // Keep the compiler happy.
+ }
if(bind(fd, reinterpret_cast<struct sockaddr*>(&addr), size) == SOCKET_ERROR)
{
@@ -927,6 +932,11 @@ repeatConnect:
{
size = sizeof(sockaddr_in6);
}
+ else
+ {
+ assert(false);
+ size = 0; // Keep the compiler happy.
+ }
if(::connect(fd, reinterpret_cast<struct sockaddr*>(&addr), size) == SOCKET_ERROR)
{
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index 9c7d05b87f4..7fddcb7f57c 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -95,17 +95,20 @@ DispatchStatus
Ice::Object::___ice_isA(Incoming& __inS, const Current& __current)
{
BasicStream* __is = __inS.is();
- BasicStream* __os = __inS.os();
+ __is->startReadEncaps();
string __id;
__is->read(__id, false);
+ __is->endReadEncaps();
bool __ret = ice_isA(__id, __current);
+ BasicStream* __os = __inS.os();
__os->write(__ret);
return DispatchOK;
}
DispatchStatus
-Ice::Object::___ice_ping(Incoming&, const Current& __current)
+Ice::Object::___ice_ping(Incoming& __inS, const Current& __current)
{
+ __inS.is()->skipEmptyEncaps();
ice_ping(__current);
return DispatchOK;
}
@@ -113,8 +116,9 @@ Ice::Object::___ice_ping(Incoming&, const Current& __current)
DispatchStatus
Ice::Object::___ice_ids(Incoming& __inS, const Current& __current)
{
- BasicStream* __os = __inS.os();
+ __inS.is()->skipEmptyEncaps();
vector<string> __ret = ice_ids(__current);
+ BasicStream* __os = __inS.os();
__os->write(&__ret[0], &__ret[0] + __ret.size(), false);
return DispatchOK;
}
@@ -122,8 +126,9 @@ Ice::Object::___ice_ids(Incoming& __inS, const Current& __current)
DispatchStatus
Ice::Object::___ice_id(Incoming& __inS, const Current& __current)
{
- BasicStream* __os = __inS.os();
+ __inS.is()->skipEmptyEncaps();
string __ret = ice_id(__current);
+ BasicStream* __os = __inS.os();
__os->write(__ret, false);
return DispatchOK;
}
@@ -350,9 +355,12 @@ DispatchStatus
Ice::Blobject::__dispatch(Incoming& in, const Current& current)
{
vector<Byte> inParams;
+ BasicStream* is = in.is();
+ is->startReadEncaps();
+ Int sz = is->getReadEncapsSize();
+ is->readBlob(inParams, sz);
+ is->endReadEncaps();
vector<Byte> outParams;
- Int sz = in.is()->getReadEncapsSize();
- in.is()->readBlob(inParams, sz);
bool ok = ice_invoke(inParams, outParams, current);
in.os()->writeBlob(outParams);
if(ok)
@@ -369,10 +377,13 @@ DispatchStatus
Ice::BlobjectArray::__dispatch(Incoming& in, const Current& current)
{
pair<const Byte*, const Byte*> inParams;
- vector<Byte> outParams;
- Int sz = in.is()->getReadEncapsSize();
- in.is()->readBlob(inParams.first, sz);
+ BasicStream* is = in.is();
+ is->startReadEncaps();
+ Int sz = is->getReadEncapsSize();
+ is->readBlob(inParams.first, sz);
inParams.second = inParams.first + sz;
+ is->endReadEncaps();
+ vector<Byte> outParams;
bool ok = ice_invoke(inParams, outParams, current);
in.os()->writeBlob(outParams);
if(ok)
@@ -389,8 +400,11 @@ DispatchStatus
Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current)
{
vector<Byte> inParams;
- Int sz = in.is()->getReadEncapsSize();
- in.is()->readBlob(inParams, sz);
+ BasicStream* is = in.is();
+ is->startReadEncaps();
+ Int sz = is->getReadEncapsSize();
+ is->readBlob(inParams, sz);
+ is->endReadEncaps();
AMD_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Object_ice_invoke(in);
try
{
@@ -411,9 +425,12 @@ DispatchStatus
Ice::BlobjectArrayAsync::__dispatch(Incoming& in, const Current& current)
{
pair<const Byte*, const Byte*> inParams;
- Int sz = in.is()->getReadEncapsSize();
- in.is()->readBlob(inParams.first, sz);
+ BasicStream* is = in.is();
+ is->startReadEncaps();
+ Int sz = is->getReadEncapsSize();
+ is->readBlob(inParams.first, sz);
inParams.second = inParams.first + sz;
+ is->endReadEncaps();
AMD_Array_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Array_Object_ice_invoke(in);
try
{
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index dbc65756136..7d6028a75c8 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -686,9 +686,13 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
{
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
- if(binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted.
+ vector<EndpointIPtr>::const_iterator r;
+ for(r = _routerEndpoints.begin(); r != _routerEndpoints.end(); ++r)
{
- return true;
+ if((*p)->equivalent(*r))
+ {
+ return true;
+ }
}
}
}
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index 24d6263ac2d..8f9b716e52c 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -374,24 +374,12 @@ IceInternal::Outgoing::finished(BasicStream& is)
{
case replyOK:
{
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward
- // oneway requests as blobs.
- //
- _is.startReadEncaps();
_state = StateOK; // The state must be set last, in case there is an exception.
break;
}
case replyUserException:
{
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward
- // oneway requests as blobs.
- //
- _is.startReadEncaps();
_state = StateUserException; // The state must be set last, in case there is an exception.
break;
}
@@ -534,6 +522,21 @@ IceInternal::Outgoing::finished(const LocalException& ex)
_monitor.notify();
}
+void
+IceInternal::Outgoing::throwUserException()
+{
+ try
+ {
+ _is.startReadEncaps();
+ _is.throwException();
+ }
+ catch(const Ice::UserException&)
+ {
+ _is.endReadEncaps();
+ throw;
+ }
+}
+
IceInternal::BatchOutgoing::BatchOutgoing(RequestHandler* handler) :
_handler(handler),
_connection(0),
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index f215964e4d9..51887688b6a 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -241,7 +241,6 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is)
case replyOK:
case replyUserException:
{
- __is->startReadEncaps();
break;
}
@@ -521,6 +520,21 @@ IceInternal::OutgoingAsync::__send()
}
void
+IceInternal::OutgoingAsync::__throwUserException()
+{
+ try
+ {
+ __is->startReadEncaps();
+ __is->throwException();
+ }
+ catch(const Ice::UserException&)
+ {
+ __is->endReadEncaps();
+ throw;
+ }
+}
+
+void
IceInternal::OutgoingAsync::handleException(const LocalExceptionWrapper& ex)
{
if(_mode == Nonmutating || _mode == Idempotent)
@@ -637,8 +651,10 @@ Ice::AMI_Object_ice_invoke::__response(bool ok) // ok == true means no user exce
vector<Byte> outParams;
try
{
+ __is->startReadEncaps();
Int sz = __is->getReadEncapsSize();
__is->readBlob(outParams, sz);
+ __is->endReadEncaps();
}
catch(const LocalException& ex)
{
@@ -673,9 +689,11 @@ Ice::AMI_Array_Object_ice_invoke::__response(bool ok) // ok == true means no use
pair<const Byte*, const Byte*> outParams;
try
{
+ __is->startReadEncaps();
Int sz = __is->getReadEncapsSize();
__is->readBlob(outParams.first, sz);
outParams.second = outParams.first + sz;
+ __is->endReadEncaps();
}
catch(const LocalException& ex)
{
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index 1191532eda2..124ae11f4bb 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -1170,19 +1170,21 @@ IceDelegateM::Ice::Object::ice_isA(const string& __id, const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
if(!__ok)
{
try
{
- __is->throwException();
+ __og.throwUserException();
}
catch(const ::Ice::UserException& __ex)
{
throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
}
}
+ BasicStream* __is = __og.is();
+ __is->startReadEncaps();
__is->read(__ret);
+ __is->endReadEncaps();
}
catch(const ::Ice::LocalException& __ex)
{
@@ -1197,24 +1199,27 @@ IceDelegateM::Ice::Object::ice_ping(const Context* context)
static const string __operation("ice_ping");
Outgoing __og(__handler.get(), __operation, ::Ice::Nonmutating, context);
bool __ok = __og.invoke();
- try
+ if(!__og.is()->b.empty())
{
- BasicStream* __is = __og.is();
- if(!__ok)
+ try
{
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
+ if(!__ok)
{
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ try
+ {
+ __og.throwUserException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
}
+ __og.is()->skipEmptyEncaps();
+ }
+ catch(const ::Ice::LocalException& __ex)
+ {
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
- }
- catch(const ::Ice::LocalException& __ex)
- {
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
}
@@ -1227,19 +1232,21 @@ IceDelegateM::Ice::Object::ice_ids(const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
if(!__ok)
{
try
{
- __is->throwException();
+ __og.throwUserException();
}
catch(const ::Ice::UserException& __ex)
{
throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
}
}
+ BasicStream* __is = __og.is();
+ __is->startReadEncaps();
__is->read(__ret, false);
+ __is->endReadEncaps();
}
catch(const ::Ice::LocalException& __ex)
{
@@ -1257,19 +1264,21 @@ IceDelegateM::Ice::Object::ice_id(const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
if(!__ok)
{
try
{
- __is->throwException();
+ __og.throwUserException();
}
catch(const ::Ice::UserException& __ex)
{
throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
}
}
+ BasicStream* __is = __og.is();
+ __is->startReadEncaps();
__is->read(__ret, false);
+ __is->endReadEncaps();
}
catch(const ::Ice::LocalException& __ex)
{
@@ -1301,8 +1310,10 @@ IceDelegateM::Ice::Object::ice_invoke(const string& operation,
try
{
BasicStream* __is = __og.is();
+ __is->startReadEncaps();
Int sz = __is->getReadEncapsSize();
__is->readBlob(outParams, sz);
+ __is->endReadEncaps();
}
catch(const ::Ice::LocalException& __ex)
{
diff --git a/cpp/src/Ice/RequestHandler.cpp b/cpp/src/Ice/RequestHandler.cpp
index cf2845c77ae..f1937fda7f7 100644
--- a/cpp/src/Ice/RequestHandler.cpp
+++ b/cpp/src/Ice/RequestHandler.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <Ice/RequestHandler.h>
+#include <Ice/Reference.h>
using namespace std;
using namespace IceInternal;
@@ -18,6 +19,8 @@ RequestHandler::~RequestHandler()
{
}
-RequestHandler::RequestHandler(const ReferencePtr& reference) : _reference(reference)
+RequestHandler::RequestHandler(const ReferencePtr& reference) :
+ _reference(reference),
+ _response(reference->getMode() == Reference::ModeTwoway)
{
}
diff --git a/cpp/src/Ice/RequestHandler.h b/cpp/src/Ice/RequestHandler.h
index 1b22794930c..7a5b585e0ee 100644
--- a/cpp/src/Ice/RequestHandler.h
+++ b/cpp/src/Ice/RequestHandler.h
@@ -48,6 +48,7 @@ protected:
RequestHandler(const ReferencePtr&);
const ReferencePtr _reference;
+ const bool _response;
};
}
diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp
index b0458637dfe..7f2ee26dadf 100644
--- a/cpp/src/Ice/StreamI.cpp
+++ b/cpp/src/Ice/StreamI.cpp
@@ -309,6 +309,12 @@ Ice::InputStreamI::endEncapsulation()
}
void
+Ice::InputStreamI::skipEncapsulation()
+{
+ _is->skipEncaps();
+}
+
+void
Ice::InputStreamI::skipSlice()
{
_is->skipSlice();
diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h
index 1f00533612d..22c9bd8079d 100644
--- a/cpp/src/Ice/StreamI.h
+++ b/cpp/src/Ice/StreamI.h
@@ -80,6 +80,7 @@ public:
virtual void skipSlice();
virtual void startEncapsulation();
+ virtual void skipEncapsulation();
virtual void endEncapsulation();
virtual void readPendingObjects();