diff options
author | Benoit Foucher <benoit@zeroc.com> | 2007-01-10 10:22:43 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2007-01-10 10:22:43 +0000 |
commit | 26c33e45e09f6c635f6a663f05e9edb51f5461ef (patch) | |
tree | 55caad6a4594a51899948b9451171098dbc7fb1e /cs/src | |
parent | Win32 fix (diff) | |
download | ice-26c33e45e09f6c635f6a663f05e9edb51f5461ef.tar.bz2 ice-26c33e45e09f6c635f6a663f05e9edb51f5461ef.tar.xz ice-26c33e45e09f6c635f6a663f05e9edb51f5461ef.zip |
Fixed bug 1650
Diffstat (limited to 'cs/src')
-rwxr-xr-x | cs/src/Ice/ConnectionI.cs | 59 | ||||
-rwxr-xr-x | cs/src/Ice/Incoming.cs | 316 | ||||
-rwxr-xr-x | cs/src/Ice/IncomingAsync.cs | 239 |
3 files changed, 208 insertions, 406 deletions
diff --git a/cs/src/Ice/ConnectionI.cs b/cs/src/Ice/ConnectionI.cs index d508b92f6f5..258ea94ebf4 100755 --- a/cs/src/Ice/ConnectionI.cs +++ b/cs/src/Ice/ConnectionI.cs @@ -1339,6 +1339,30 @@ namespace Ice } } + public void invokeException(LocalException ex, int invokeNum) + { + // + // Fatal exception while invoking a request. Since sendResponse/sendNoResponse isn't + // called in case of a fatal exception we decrement _dispatchCount here. + // + + lock(this) + { + setState(StateClosed, ex); + + if(invokeNum > 0) + { + Debug.Assert(_dispatchCount > 0); + _dispatchCount -= invokeNum; + Debug.Assert(_dispatchCount >= 0); + if(_dispatchCount == 0) + { + Monitor.PulseAll(this); + } + } + } + } + public string type() { return _type; // No mutex lock, _type is immutable. @@ -2030,19 +2054,7 @@ namespace Ice } catch(LocalException ex) { - lock(this) - { - setState(StateClosed, ex); - } - } - catch(System.Exception ex) - { - lock(this) - { - UnknownException uex = new UnknownException(); - uex.unknown = ex.ToString(); - setState(StateClosed, uex); - } + invokeException(ex, invokeNum); } finally { @@ -2050,26 +2062,7 @@ namespace Ice { reclaimIncoming(inc); } - } - - // - // If invoke() above raised an exception, and therefore - // neither sendResponse() nor sendNoResponse() has been - // called, then we must decrement _dispatchCount here. - // - if(invokeNum > 0) - { - lock(this) - { - Debug.Assert(_dispatchCount > 0); - _dispatchCount -= invokeNum; - Debug.Assert(_dispatchCount >= 0); - if(_dispatchCount == 0) - { - Monitor.PulseAll(this); - } - } - } + } } private void run() diff --git a/cs/src/Ice/Incoming.cs b/cs/src/Ice/Incoming.cs index 3094e45dacc..03b39760b6a 100755 --- a/cs/src/Ice/Incoming.cs +++ b/cs/src/Ice/Incoming.cs @@ -119,158 +119,16 @@ namespace IceInternal os_.instance().initializationData().logger.warning(sw.ToString()); } } - - protected internal Ice.Current current_; - protected internal Ice.Object servant_; - protected internal Ice.ServantLocator locator_; - protected internal Ice.LocalObject cookie_; - - protected internal bool response_; - protected internal byte compress_; - - protected internal BasicStream os_; - - protected Ice.ConnectionI connection_; - } - - sealed public class Incoming : IncomingBase - { - public Incoming(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, - bool response, byte compress, int requestId) - : base(instance, connection, adapter, response, compress, requestId) - { - _is = new BasicStream(instance); - } - - // - // These functions allow this object to be reused, rather than reallocated. - // - public override void reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, - bool response, byte compress, int requestId) - { - if(_is == null) - { - _is = new BasicStream(instance); - } - - base.reset(instance, connection, adapter, response, compress, requestId); - } - - public override void reclaim() - { - if(_is != null) - { - _is.reset(); - } - - base.reclaim(); - } - - public void invoke(ServantManager servantManager) - { - // - // Read the current. - // - current_.id.read__(_is); - - // - // For compatibility with the old FacetPath. - // - string[] facetPath = _is.readStringSeq(); - if(facetPath.Length > 0) - { - if(facetPath.Length > 1) - { - throw new Ice.MarshalException(); - } - current_.facet = facetPath[0]; - } - else - { - current_.facet = ""; - } - current_.operation = _is.readString(); - current_.mode = (Ice.OperationMode)(int)_is.readByte(); - int sz = _is.readSize(); - while(sz-- > 0) - { - string first = _is.readString(); - string second = _is.readString(); - if(current_.ctx == null) - { - current_.ctx = new Ice.Context(); - } - current_.ctx[first] = second; - } - - _is.startReadEncaps(); - - if(response_) - { - Debug.Assert(os_.size() == Protocol.headerSize + 4); // Dispatch status position. - os_.writeByte((byte)0); - os_.startWriteEncaps(); - } - - // Initialize status to some value, to keep the compiler happy. - DispatchStatus status = DispatchStatus.DispatchOK; - - // - // Don't put the code above into the try block below. Exceptions - // in the code above are considered fatal, and must propagate to - // the caller of this operation. - // - + protected internal void handleException__(System.Exception exc) + { try { - try - { - if(servantManager != null) - { - servant_ = servantManager.findServant(current_.id, current_.facet); - if(servant_ == null) - { - locator_ = servantManager.findServantLocator(current_.id.category); - if(locator_ == null && current_.id.category.Length > 0) - { - locator_ = servantManager.findServantLocator(""); - } - if(locator_ != null) - { - servant_ = locator_.locate(current_, out cookie_); - } - } - } - if(servant_ == null) - { - if(servantManager != null && servantManager.hasServant(current_.id)) - { - status = DispatchStatus.DispatchFacetNotExist; - } - else - { - status = DispatchStatus.DispatchObjectNotExist; - } - } - else - { - status = servant_.dispatch__(this, current_); - } - } - finally - { - if(locator_ != null && servant_ != null && status != DispatchStatus.DispatchAsync) - { - locator_.finished(current_, servant_, cookie_); - } - } + throw exc; } catch(Ice.RequestFailedException ex) { - _is.endReadEncaps(); - - if(ex.id.name == null) + if(ex.id == null) { ex.id = current_.id; } @@ -339,8 +197,6 @@ namespace IceInternal } catch(Ice.UnknownLocalException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -364,8 +220,6 @@ namespace IceInternal } catch(Ice.UnknownUserException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -389,8 +243,6 @@ namespace IceInternal } catch(Ice.UnknownException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -414,8 +266,6 @@ namespace IceInternal } catch(Ice.LocalException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -440,8 +290,6 @@ namespace IceInternal catch(Ice.UserException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -466,8 +314,6 @@ namespace IceInternal catch(System.Exception ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -489,6 +335,160 @@ namespace IceInternal return; } + } + + protected internal Ice.Current current_; + protected internal Ice.Object servant_; + protected internal Ice.ServantLocator locator_; + protected internal Ice.LocalObject cookie_; + + protected internal bool response_; + protected internal byte compress_; + + protected internal BasicStream os_; + + protected Ice.ConnectionI connection_; + } + + sealed public class Incoming : IncomingBase + { + public Incoming(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, + bool response, byte compress, int requestId) + : base(instance, connection, adapter, response, compress, requestId) + { + _is = new BasicStream(instance); + } + + // + // These functions allow this object to be reused, rather than reallocated. + // + public override void reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, + bool response, byte compress, int requestId) + { + if(_is == null) + { + _is = new BasicStream(instance); + } + + base.reset(instance, connection, adapter, response, compress, requestId); + } + + public override void reclaim() + { + if(_is != null) + { + _is.reset(); + } + + base.reclaim(); + } + + public void invoke(ServantManager servantManager) + { + // + // Read the current. + // + current_.id.read__(_is); + + // + // For compatibility with the old FacetPath. + // + string[] facetPath = _is.readStringSeq(); + if(facetPath.Length > 0) + { + if(facetPath.Length > 1) + { + throw new Ice.MarshalException(); + } + current_.facet = facetPath[0]; + } + else + { + current_.facet = ""; + } + + current_.operation = _is.readString(); + current_.mode = (Ice.OperationMode)(int)_is.readByte(); + int sz = _is.readSize(); + while(sz-- > 0) + { + string first = _is.readString(); + string second = _is.readString(); + if(current_.ctx == null) + { + current_.ctx = new Ice.Context(); + } + current_.ctx[first] = second; + } + + _is.startReadEncaps(); + + if(response_) + { + Debug.Assert(os_.size() == Protocol.headerSize + 4); // Dispatch status position. + os_.writeByte((byte)0); + os_.startWriteEncaps(); + } + + // Initialize status to some value, to keep the compiler happy. + DispatchStatus status = DispatchStatus.DispatchOK; + + // + // Don't put the code above into the try block below. Exceptions + // in the code above are considered fatal, and must propagate to + // the caller of this operation. + // + + try + { + try + { + if(servantManager != null) + { + servant_ = servantManager.findServant(current_.id, current_.facet); + if(servant_ == null) + { + locator_ = servantManager.findServantLocator(current_.id.category); + if(locator_ == null && current_.id.category.Length > 0) + { + locator_ = servantManager.findServantLocator(""); + } + if(locator_ != null) + { + servant_ = locator_.locate(current_, out cookie_); + } + } + } + if(servant_ == null) + { + if(servantManager != null && servantManager.hasServant(current_.id)) + { + status = DispatchStatus.DispatchFacetNotExist; + } + else + { + status = DispatchStatus.DispatchObjectNotExist; + } + } + else + { + status = servant_.dispatch__(this, current_); + } + } + finally + { + if(locator_ != null && servant_ != null && status != DispatchStatus.DispatchAsync) + { + locator_.finished(current_, servant_, cookie_); + } + } + } + catch(System.Exception ex) + { + _is.endReadEncaps(); + handleException__(ex); + return; + } // // Don't put the code below into the try block above. Exceptions diff --git a/cs/src/Ice/IncomingAsync.cs b/cs/src/Ice/IncomingAsync.cs index 412729398d7..c77e4f4851e 100755 --- a/cs/src/Ice/IncomingAsync.cs +++ b/cs/src/Ice/IncomingAsync.cs @@ -23,9 +23,9 @@ namespace IceInternal { try { - if(locator_ != null && servant_ != null) + if(!servantLocatorFinished__()) { - locator_.finished(current_, servant_, cookie_); + return; } if(response_) @@ -55,13 +55,7 @@ namespace IceInternal } catch(Ice.LocalException ex) { - connection_.exception(ex); - } - catch(System.Exception ex) - { - Ice.UnknownException uex = new Ice.UnknownException(); - uex.unknown = ex.ToString(); - connection_.exception(uex); + connection_.invokeException(ex, 1); } } @@ -69,218 +63,16 @@ namespace IceInternal { try { - if(locator_ != null && servant_ != null) + if(!servantLocatorFinished__()) { - locator_.finished(current_, servant_, cookie_); + return; } - try - { - throw exc; - } - catch(Ice.RequestFailedException ex) - { - if(ex.id.name == null) - { - ex.id = current_.id; - } - - if(ex.facet == null) - { - ex.facet = current_.facet; - } - - if(ex.operation == null || ex.operation.Length == 0) - { - ex.operation = current_.operation; - } - - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 1) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - if(ex is Ice.ObjectNotExistException) - { - os_.writeByte((byte)DispatchStatus.DispatchObjectNotExist); - } - else if(ex is Ice.FacetNotExistException) - { - os_.writeByte((byte)DispatchStatus.DispatchFacetNotExist); - } - else if(ex is Ice.OperationNotExistException) - { - os_.writeByte((byte)DispatchStatus.DispatchOperationNotExist); - } - else - { - Debug.Assert(false); - } - ex.id.write__(os_); - - // - // For compatibility with the old FacetPath. - // - if(ex.facet == null || ex.facet.Length == 0) - { - os_.writeStringSeq(null); - } - else - { - string[] facetPath = { ex.facet }; - os_.writeStringSeq(facetPath); - } - - os_.writeString(ex.operation); - - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.UnknownLocalException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownLocalException); - os_.writeString(ex.unknown); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.UnknownUserException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownUserException); - os_.writeString(ex.unknown); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.UnknownException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownException); - os_.writeString(ex.unknown); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.LocalException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownLocalException); - os_.writeString(ex.ToString()); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.UserException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownUserException); - os_.writeString(ex.ToString()); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(System.Exception ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownException); - os_.writeString(ex.ToString()); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } + handleException__(exc); } catch(Ice.LocalException ex) { - connection_.exception(ex); - } - catch(System.Exception ex) - { - Ice.UnknownException uex = new Ice.UnknownException(); - uex.unknown = ex.ToString(); - connection_.exception(uex); + connection_.invokeException(ex, 1); } } @@ -288,6 +80,23 @@ namespace IceInternal { return os_; } + + private bool servantLocatorFinished__() + { + try + { + if(locator_ != null && servant_ != null) + { + locator_.finished(current_, servant_, cookie_); + } + return true; + } + catch(System.Exception ex) + { + handleException__(ex); + return false; + } + } } } |