diff options
Diffstat (limited to 'cpp/src/Ice/OutgoingAsync.cpp')
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 596 |
1 files changed, 298 insertions, 298 deletions
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index e03c3b58d57..ad53705d9e9 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -56,148 +56,148 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is) try { - __is->swap(is); - - Byte b; - __is->read(b); - status = static_cast<DispatchStatus>(b); - - switch(status) - { - case DispatchOK: - case DispatchUserException: - { - __is->startReadEncaps(); - break; - } - - case DispatchObjectNotExist: - case DispatchFacetNotExist: - case DispatchOperationNotExist: - { - Identity ident; - ident.__read(__is); - - // - // For compatibility with the old FacetPath. - // - vector<string> facetPath; - __is->read(facetPath); - string facet; - if(!facetPath.empty()) - { - if(facetPath.size() > 1) - { - throw MarshalException(__FILE__, __LINE__); - } - facet.swap(facetPath[0]); - } - - string operation; - __is->read(operation, false); - - auto_ptr<RequestFailedException> ex; - switch(static_cast<DispatchStatus>(status)) - { - case DispatchObjectNotExist: - { - ex.reset(new ObjectNotExistException(__FILE__, __LINE__)); - break; - } - - case DispatchFacetNotExist: - { - ex.reset(new FacetNotExistException(__FILE__, __LINE__)); - break; - } - - case DispatchOperationNotExist: - { - ex.reset(new OperationNotExistException(__FILE__, __LINE__)); - break; - } - - default: - { - assert(false); - break; - } - } - - ex->id = ident; - ex->facet = facet; - ex->operation = operation; - ex->ice_throw(); - } - - case DispatchUnknownException: - case DispatchUnknownLocalException: - case DispatchUnknownUserException: - { - string unknown; - __is->read(unknown, false); - - auto_ptr<UnknownException> ex; - switch(static_cast<DispatchStatus>(status)) - { - case DispatchUnknownException: - { - ex.reset(new UnknownException(__FILE__, __LINE__)); - break; - } - - case DispatchUnknownLocalException: - { - ex.reset(new UnknownLocalException(__FILE__, __LINE__)); - break; - } - - case DispatchUnknownUserException: - { - ex.reset(new UnknownUserException(__FILE__, __LINE__)); - break; - } - - default: - { - assert(false); - break; - } - } - - ex->unknown = unknown; - ex->ice_throw(); - } - - default: - { - throw UnknownReplyStatusException(__FILE__, __LINE__); - } - } + __is->swap(is); + + Byte b; + __is->read(b); + status = static_cast<DispatchStatus>(b); + + switch(status) + { + case DispatchOK: + case DispatchUserException: + { + __is->startReadEncaps(); + break; + } + + case DispatchObjectNotExist: + case DispatchFacetNotExist: + case DispatchOperationNotExist: + { + Identity ident; + ident.__read(__is); + + // + // For compatibility with the old FacetPath. + // + vector<string> facetPath; + __is->read(facetPath); + string facet; + if(!facetPath.empty()) + { + if(facetPath.size() > 1) + { + throw MarshalException(__FILE__, __LINE__); + } + facet.swap(facetPath[0]); + } + + string operation; + __is->read(operation, false); + + auto_ptr<RequestFailedException> ex; + switch(static_cast<DispatchStatus>(status)) + { + case DispatchObjectNotExist: + { + ex.reset(new ObjectNotExistException(__FILE__, __LINE__)); + break; + } + + case DispatchFacetNotExist: + { + ex.reset(new FacetNotExistException(__FILE__, __LINE__)); + break; + } + + case DispatchOperationNotExist: + { + ex.reset(new OperationNotExistException(__FILE__, __LINE__)); + break; + } + + default: + { + assert(false); + break; + } + } + + ex->id = ident; + ex->facet = facet; + ex->operation = operation; + ex->ice_throw(); + } + + case DispatchUnknownException: + case DispatchUnknownLocalException: + case DispatchUnknownUserException: + { + string unknown; + __is->read(unknown, false); + + auto_ptr<UnknownException> ex; + switch(static_cast<DispatchStatus>(status)) + { + case DispatchUnknownException: + { + ex.reset(new UnknownException(__FILE__, __LINE__)); + break; + } + + case DispatchUnknownLocalException: + { + ex.reset(new UnknownLocalException(__FILE__, __LINE__)); + break; + } + + case DispatchUnknownUserException: + { + ex.reset(new UnknownUserException(__FILE__, __LINE__)); + break; + } + + default: + { + assert(false); + break; + } + } + + ex->unknown = unknown; + ex->ice_throw(); + } + + default: + { + throw UnknownReplyStatusException(__FILE__, __LINE__); + } + } } catch(const LocalException& ex) { - __finished(ex); - return; + __finished(ex); + return; } assert(status == DispatchOK || status == DispatchUserException); try { - __response(status == DispatchOK); + __response(status == DispatchOK); } catch(const Exception& ex) { - warning(ex); + warning(ex); } catch(const std::exception& ex) { - warning(ex); + warning(ex); } catch(...) { - warning(); + warning(); } cleanup(); @@ -210,48 +210,48 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc) if(__os) // Don't retry if cleanup() was already called. { - // - // A CloseConnectionException indicates graceful server - // shutdown, and is therefore always repeatable without - // violating "at-most-once". That's because by sending a close - // connection message, the server guarantees that all - // outstanding requests can safely be repeated. Otherwise, we - // can also retry if the operation mode is Nonmutating or - // Idempotent. - // - // An ObjectNotExistException can always be retried as - // well without violating "at-most-once". - // - if(_mode == Nonmutating || _mode == Idempotent || dynamic_cast<const CloseConnectionException*>(&exc) || - dynamic_cast<const ObjectNotExistException*>(&exc)) - { - try - { - _proxy->__handleException(_delegate, exc, _cnt); - __send(); - return; - } - catch(const LocalException&) - { - } - } + // + // A CloseConnectionException indicates graceful server + // shutdown, and is therefore always repeatable without + // violating "at-most-once". That's because by sending a close + // connection message, the server guarantees that all + // outstanding requests can safely be repeated. Otherwise, we + // can also retry if the operation mode is Nonmutating or + // Idempotent. + // + // An ObjectNotExistException can always be retried as + // well without violating "at-most-once". + // + if(_mode == Nonmutating || _mode == Idempotent || dynamic_cast<const CloseConnectionException*>(&exc) || + dynamic_cast<const ObjectNotExistException*>(&exc)) + { + try + { + _proxy->__handleException(_delegate, exc, _cnt); + __send(); + return; + } + catch(const LocalException&) + { + } + } } try { - ice_exception(exc); + ice_exception(exc); } catch(const Exception& ex) { - warning(ex); + warning(ex); } catch(const std::exception& ex) { - warning(ex); + warning(ex); } catch(...) { - warning(); + warning(); } cleanup(); @@ -259,90 +259,90 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc) void IceInternal::OutgoingAsync::__prepare(const ObjectPrx& prx, const string& operation, OperationMode mode, - const Context* context) + const Context* context) { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_monitor); try { - // - // We must first wait for other requests to finish. - // - while(__os) - { - _monitor.wait(); - } - - // - // Can't call async via a oneway proxy. - // - prx->__checkTwowayOnly(operation); - - _proxy = prx; + // + // We must first wait for other requests to finish. + // + while(__os) + { + _monitor.wait(); + } + + // + // Can't call async via a oneway proxy. + // + prx->__checkTwowayOnly(operation); + + _proxy = prx; _delegate = 0; - _cnt = 0; - _mode = mode; - - ReferencePtr ref = _proxy->__reference(); - assert(!__is); - __is = new BasicStream(ref->getInstance().get()); - assert(!__os); - __os = new BasicStream(ref->getInstance().get()); - - __os->writeBlob(requestHdr, sizeof(requestHdr)); - - ref->getIdentity().__write(__os); - - // - // For compatibility with the old FacetPath. - // - if(ref->getFacet().empty()) - { - __os->write(static_cast<string*>(0), static_cast<string*>(0)); - } - else - { - string facet = ref->getFacet(); - __os->write(&facet, &facet + 1); - } - - __os->write(operation, false); - - __os->write(static_cast<Byte>(_mode)); - - if(context != 0) - { - // - // Explicit context - // - __write(__os, *context, __U__Context()); - } - else - { - // - // Implicit context - // - const ImplicitContextIPtr& implicitContext = - ref->getInstance()->getImplicitContext(); - - const Context& prxContext = ref->getContext()->getValue(); - - if(implicitContext == 0) - { - __write(__os, prxContext, __U__Context()); - } - else - { - implicitContext->write(prxContext, __os); - } - } - - __os->startWriteEncaps(); + _cnt = 0; + _mode = mode; + + ReferencePtr ref = _proxy->__reference(); + assert(!__is); + __is = new BasicStream(ref->getInstance().get()); + assert(!__os); + __os = new BasicStream(ref->getInstance().get()); + + __os->writeBlob(requestHdr, sizeof(requestHdr)); + + ref->getIdentity().__write(__os); + + // + // For compatibility with the old FacetPath. + // + if(ref->getFacet().empty()) + { + __os->write(static_cast<string*>(0), static_cast<string*>(0)); + } + else + { + string facet = ref->getFacet(); + __os->write(&facet, &facet + 1); + } + + __os->write(operation, false); + + __os->write(static_cast<Byte>(_mode)); + + if(context != 0) + { + // + // Explicit context + // + __write(__os, *context, __U__Context()); + } + else + { + // + // Implicit context + // + const ImplicitContextIPtr& implicitContext = + ref->getInstance()->getImplicitContext(); + + const Context& prxContext = ref->getContext()->getValue(); + + if(implicitContext == 0) + { + __write(__os, prxContext, __U__Context()); + } + else + { + implicitContext->write(prxContext, __os); + } + } + + __os->startWriteEncaps(); } catch(const LocalException& ex) { - cleanup(); - ex.ice_throw(); + cleanup(); + ex.ice_throw(); } } @@ -353,37 +353,37 @@ IceInternal::OutgoingAsync::__send() try { - while(true) - { - bool compress; - _delegate = _proxy->__getDelegate(); - Ice::ConnectionIPtr connection = _delegate->__getConnection(compress); - try - { - connection->sendAsyncRequest(__os, this, compress); - - // - // Don't do anything after sendAsyncRequest() returned - // without an exception. I such case, there will be - // callbacks, i.e., calls to the __finished() - // functions. Since there is no mutex protection, we - // cannot modify state here and in such callbacks. - // - return; - } - catch(const LocalExceptionWrapper& ex) - { - _proxy->__handleExceptionWrapper(_delegate, ex); - } - catch(const LocalException& ex) - { - _proxy->__handleException(_delegate, ex, _cnt); - } - } + while(true) + { + bool compress; + _delegate = _proxy->__getDelegate(); + Ice::ConnectionIPtr connection = _delegate->__getConnection(compress); + try + { + connection->sendAsyncRequest(__os, this, compress); + + // + // Don't do anything after sendAsyncRequest() returned + // without an exception. I such case, there will be + // callbacks, i.e., calls to the __finished() + // functions. Since there is no mutex protection, we + // cannot modify state here and in such callbacks. + // + return; + } + catch(const LocalExceptionWrapper& ex) + { + _proxy->__handleExceptionWrapper(_delegate, ex); + } + catch(const LocalException& ex) + { + _proxy->__handleException(_delegate, ex, _cnt); + } + } } catch(const LocalException& ex) { - __finished(ex); + __finished(ex); } } @@ -392,13 +392,13 @@ IceInternal::OutgoingAsync::warning(const Exception& ex) const { if(__os) // Don't print anything if cleanup() was already called. { - ReferencePtr ref = _proxy->__reference(); - if(ref->getInstance()->initializationData().properties-> - getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) - { - Warning out(ref->getInstance()->initializationData().logger); - out << "Ice::Exception raised by AMI callback:\n" << ex; - } + ReferencePtr ref = _proxy->__reference(); + if(ref->getInstance()->initializationData().properties-> + getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) + { + Warning out(ref->getInstance()->initializationData().logger); + out << "Ice::Exception raised by AMI callback:\n" << ex; + } } } @@ -407,13 +407,13 @@ IceInternal::OutgoingAsync::warning(const std::exception& ex) const { if(__os) // Don't print anything if cleanup() was already called. { - ReferencePtr ref = _proxy->__reference(); - if(ref->getInstance()->initializationData().properties-> - getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) - { - Warning out(ref->getInstance()->initializationData().logger); - out << "std::exception raised by AMI callback:\n" << ex.what(); - } + ReferencePtr ref = _proxy->__reference(); + if(ref->getInstance()->initializationData().properties-> + getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) + { + Warning out(ref->getInstance()->initializationData().logger); + out << "std::exception raised by AMI callback:\n" << ex.what(); + } } } @@ -422,13 +422,13 @@ IceInternal::OutgoingAsync::warning() const { if(__os) // Don't print anything if cleanup() was already called. { - ReferencePtr ref = _proxy->__reference(); - if(ref->getInstance()->initializationData().properties-> - getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) - { - Warning out(ref->getInstance()->initializationData().logger); - out << "unknown exception raised by AMI callback"; - } + ReferencePtr ref = _proxy->__reference(); + if(ref->getInstance()->initializationData().properties-> + getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) + { + Warning out(ref->getInstance()->initializationData().logger); + out << "unknown exception raised by AMI callback"; + } } } @@ -445,18 +445,18 @@ IceInternal::OutgoingAsync::cleanup() void Ice::AMI_Object_ice_invoke::__invoke(const ObjectPrx& prx, const string& operation, OperationMode mode, - const vector<Byte>& inParams, const Context* context) + const vector<Byte>& inParams, const Context* context) { try { - __prepare(prx, operation, mode, context); - __os->writeBlob(inParams); - __os->endWriteEncaps(); + __prepare(prx, operation, mode, context); + __os->writeBlob(inParams); + __os->endWriteEncaps(); } catch(const LocalException& ex) { - __finished(ex); - return; + __finished(ex); + return; } __send(); } @@ -467,31 +467,31 @@ Ice::AMI_Object_ice_invoke::__response(bool ok) // ok == true means no user exce vector<Byte> outParams; try { - Int sz = __is->getReadEncapsSize(); - __is->readBlob(outParams, sz); + Int sz = __is->getReadEncapsSize(); + __is->readBlob(outParams, sz); } catch(const LocalException& ex) { - __finished(ex); - return; + __finished(ex); + return; } ice_response(ok, outParams); } void Ice::AMI_Array_Object_ice_invoke::__invoke(const ObjectPrx& prx, const string& operation, OperationMode mode, - const pair<const Byte*, const Byte*>& inParams, const Context* context) + const pair<const Byte*, const Byte*>& inParams, const Context* context) { try { - __prepare(prx, operation, mode, context); - __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first)); - __os->endWriteEncaps(); + __prepare(prx, operation, mode, context); + __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first)); + __os->endWriteEncaps(); } catch(const LocalException& ex) { - __finished(ex); - return; + __finished(ex); + return; } __send(); } @@ -502,14 +502,14 @@ Ice::AMI_Array_Object_ice_invoke::__response(bool ok) // ok == true means no use pair<const Byte*, const Byte*> outParams; try { - Int sz = __is->getReadEncapsSize(); - __is->readBlob(outParams.first, sz); - outParams.second = outParams.first + sz; + Int sz = __is->getReadEncapsSize(); + __is->readBlob(outParams.first, sz); + outParams.second = outParams.first + sz; } catch(const LocalException& ex) { - __finished(ex); - return; + __finished(ex); + return; } ice_response(ok, outParams); } |