public static void dumpStream(BasicStream stream) { int pos = stream.pos(); stream.pos(0); byte[] data = new byte[stream.size()]; stream.readBlob(data); dumpOctets(data); stream.pos(pos); }
public BatchRequestQueue(Instance instance, bool datagram) { Ice.InitializationData initData = instance.initializationData(); _interceptor = initData.batchRequestInterceptor; _batchStreamInUse = false; _batchRequestNum = 0; _batchStream = new BasicStream(instance, Ice.Util.currentProtocolEncoding); _batchStream.writeBlob(Protocol.requestBatchHdr); _batchMarker = _batchStream.size(); _request = new BatchRequestI(this); _maxSize = instance.batchAutoFlushSize(); if (_maxSize > 0 && datagram) { int udpSndSize = initData.properties.getPropertyAsIntWithDefault("Ice.UDP.SndSize", 65535 - _udpOverhead); if (udpSndSize < _maxSize) { _maxSize = udpSndSize; } } }
public void sendResponse(int requestId, BasicStream os, byte status, bool amd) { Ice.AsyncCallback cb = null; OutgoingAsyncBase outAsync; lock (this) { Debug.Assert(_response); os.pos(Protocol.replyHdr.Length + 4); if (_traceLevels.protocol >= 1) { fillInValue(os, 10, os.size()); TraceUtil.traceRecv(os, _logger, _traceLevels); } if (_asyncRequests.TryGetValue(requestId, out outAsync)) { _asyncRequests.Remove(requestId); outAsync.getIs().swap(os); cb = outAsync.completed(); } } if (cb != null) { if (amd) { outAsync.invokeCompletedAsync(cb); } else { outAsync.invokeCompleted(cb); } } _adapter.decDirectCount(); }
public void finished(BasicStream istr) { _m.Lock(); try { Debug.Assert(_handler.getReference().getMode() == Reference.Mode.ModeTwoway); // Only for twoways. Debug.Assert(_state <= StateInProgress); if (_remoteObserver != null) { _remoteObserver.reply(istr.size() - Protocol.headerSize - 4); _remoteObserver.detach(); _remoteObserver = null; } if (_is == null) { _is = new IceInternal.BasicStream(_handler.getReference().getInstance(), Ice.Util.currentProtocolEncoding); } _is.swap(istr); byte replyStatus = _is.readByte(); switch (replyStatus) { case ReplyStatus.replyOK: { _state = StateOK; // The state must be set last, in case there is an exception. break; } case ReplyStatus.replyUserException: { if (_observer != null) { _observer.userException(); } _state = StateUserException; // The state must be set last, in case there is an exception. break; } case ReplyStatus.replyObjectNotExist: case ReplyStatus.replyFacetNotExist: case ReplyStatus.replyOperationNotExist: { Ice.RequestFailedException ex = null; switch (replyStatus) { case ReplyStatus.replyObjectNotExist: { ex = new Ice.ObjectNotExistException(); break; } case ReplyStatus.replyFacetNotExist: { ex = new Ice.FacetNotExistException(); break; } case ReplyStatus.replyOperationNotExist: { ex = new Ice.OperationNotExistException(); break; } default: { Debug.Assert(false); break; } } ex.id = new Ice.Identity(); ex.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(); } ex.facet = facetPath[0]; } else { ex.facet = ""; } ex.operation = _is.readString(); _exception = ex; _state = StateLocalException; // The state must be set last, in case there is an exception. break; } case ReplyStatus.replyUnknownException: case ReplyStatus.replyUnknownLocalException: case ReplyStatus.replyUnknownUserException: { Ice.UnknownException ex = null; switch (replyStatus) { case ReplyStatus.replyUnknownException: { ex = new Ice.UnknownException(); break; } case ReplyStatus.replyUnknownLocalException: { ex = new Ice.UnknownLocalException(); break; } case ReplyStatus.replyUnknownUserException: { ex = new Ice.UnknownUserException(); break; } default: { Debug.Assert(false); break; } } ex.unknown = _is.readString(); _exception = ex; _state = StateLocalException; // The state must be set last, in case there is an exception. break; } default: { _exception = new Ice.UnknownReplyStatusException(); _state = StateLocalException; break; } } _m.Notify(); } finally { _m.Unlock(); } }
private void invokeAll(BasicStream os, int requestId, int batchRequestNum) { if (batchRequestNum > 0) { os.pos(Protocol.requestBatchHdr.Length); } else { os.pos(Protocol.requestHdr.Length); } if (_traceLevels.protocol >= 1) { fillInValue(os, 10, os.size()); if (requestId > 0) { fillInValue(os, Protocol.headerSize, requestId); } else if (batchRequestNum > 0) { fillInValue(os, Protocol.headerSize, batchRequestNum); } TraceUtil.traceSend(os, _logger, _traceLevels); } int invokeNum = batchRequestNum > 0 ? batchRequestNum : 1; ServantManager servantManager = _adapter.getServantManager(); try { while (invokeNum > 0) { // // Increase the direct count for the dispatch. We increase it again here for // each dispatch. It's important for the direct count to be > 0 until the last // collocated request response is sent to make sure the thread pool isn't // destroyed before. // try { _adapter.incDirectCount(); } catch (Ice.ObjectAdapterDeactivatedException ex) { handleException(requestId, ex, false); break; } Incoming @in = new Incoming(_reference.getInstance(), this, null, _adapter, _response, (byte)0, requestId); @in.invoke(servantManager, os); --invokeNum; } } catch (Ice.LocalException ex) { invokeException(requestId, ex, invokeNum, false); // Fatal invocation exception } _adapter.decDirectCount(); }