public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { lock(this) { if(_exception != null) { return; // The request has been notified of a failure already. } if(!initialized()) { LinkedListNode<ProxyOutgoingAsyncBase> p = _requests.First; while(p != null) { if(p.Value == outAsync) { _requests.Remove(p); Ice.AsyncCallback cb = outAsync.completed(ex); if(cb != null) { outAsync.invokeCompletedAsync(cb); } return; } p = p.Next; } Debug.Assert(false); // The request has to be queued if it timed out and we're not initialized yet. } } _connection.asyncRequestCanceled(outAsync, ex); }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { Debug.Assert(_outAsync == outAsync); if(_retryQueue.cancel(this)) { Ice.AsyncCallback cb = _outAsync.completed(ex); if(cb != null) { _outAsync.invokeCompletedAsync(cb); } } }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { Debug.Assert(_outAsync == outAsync); if(_retryQueue.cancel(this)) { if(_instance.traceLevels().retry >= 1) { string s = "operation retry canceled\n" + ex; _instance.initializationData().logger.trace(_instance.traceLevels().retryCat, s); } Ice.AsyncCallback cb = _outAsync.completed(ex); if(cb != null) { _outAsync.invokeCompletedAsync(cb); } } }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { lock(this) { int requestId; if(_sendAsyncRequests.TryGetValue(outAsync, out requestId)) { if(requestId > 0) { _asyncRequests.Remove(requestId); } _sendAsyncRequests.Remove(outAsync); Ice.AsyncCallback cb = outAsync.completed(ex); if(cb != null) { outAsync.invokeCompletedAsync(cb); } _adapter.decDirectCount(); // invokeAll won't be called, decrease the direct count. return; } if(outAsync is OutgoingAsync) { OutgoingAsync o = (OutgoingAsync)outAsync; Debug.Assert(o != null); foreach(KeyValuePair<int, OutgoingAsyncBase> e in _asyncRequests) { if(e.Value == o) { _asyncRequests.Remove(e.Key); Ice.AsyncCallback cb = outAsync.completed(ex); if(cb != null) { outAsync.invokeCompletedAsync(cb); } return; } } } } }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { _connection.asyncRequestCanceled(outAsync, ex); }
public override void HandleInvokeResponse(bool ok, OutgoingAsyncBase og) => SetResult(((InvokeOutgoingAsyncT)og).GetResult(ok));
private bool sentAsync(OutgoingAsyncBase outAsync) { lock(this) { if(!_sendAsyncRequests.Remove(outAsync)) { return false; // The request timed-out. } } Ice.AsyncCallback cb = outAsync.sent(); if(cb != null) { outAsync.invokeSent(cb); } return true; }
public override void HandleInvokeResponse(bool ok, OutgoingAsyncBase og) => SetResult(((ProxyGetConnection)og).GetConnection() !);
public bool sendAsyncRequest(OutgoingAsyncBase outAsync, out Ice.AsyncCallback sentCallback) { lock(this) { if(!_initialized) { outAsync.cancelable(this); // This will throw if the request is canceled } try { if(!initialized()) { _requests.AddLast(new Request(outAsync)); sentCallback = null; return false; } } catch(Ice.LocalException ex) { throw new RetryException(ex); } } return outAsync.send(_connection, _compress, _response, out sentCallback); }
public void AsyncRequestCanceled(OutgoingAsyncBase outAsync, System.Exception ex) => _connection.AsyncRequestCanceled(outAsync, ex);
public int sendAsyncRequest(OutgoingAsyncBase og, bool compress, bool response, int batchRequestNum) { OutputStream os = og.getOs(); lock(this) { // // If the exception is closed before we even have a chance // to send our request, we always try to send the request // again. // if(_exception != null) { throw new RetryException(_exception); } Debug.Assert(_state > StateNotValidated); Debug.Assert(_state < StateClosing); // // Ensure the message isn't bigger than what we can send with the // transport. // _transceiver.checkSendSize(os.getBuffer()); // // Notify the request that it's cancelable with this connection. // This will throw if the request is canceled. // og.cancelable(this); int requestId = 0; if(response) { // // Create a new unique request ID. // requestId = _nextRequestId++; if(requestId <= 0) { _nextRequestId = 1; requestId = _nextRequestId++; } // // Fill in the request ID. // os.pos(Protocol.headerSize); os.writeInt(requestId); } else if(batchRequestNum > 0) { os.pos(Protocol.headerSize); os.writeInt(batchRequestNum); } og.attachRemoteObserver(initConnectionInfo(), _endpoint, requestId); int status = OutgoingAsyncBase.AsyncStatusQueued; try { OutgoingMessage message = new OutgoingMessage(og, os, compress, requestId); status = sendMessage(message); } catch(Ice.LocalException ex) { setState(StateClosed, ex); Debug.Assert(_exception != null); throw _exception; } if(response) { // // Add to the async requests map. // _asyncRequests[requestId] = og; } return status; } }
public bool invokeAsyncBatchRequests(OutgoingAsyncBase outAsync, out Ice.AsyncCallback sentCallback) { int invokeNum; lock(this) { while(_batchStreamInUse) { Monitor.Wait(this); } invokeNum = _batchRequestNum; if(_batchRequestNum > 0) { outAsync.cancelable(this); // This will throw if the request is canceled _sendAsyncRequests.Add(outAsync, 0); Debug.Assert(!_batchStream.isEmpty()); _batchStream.swap(outAsync.getOs()); // // Reset the batch stream. // BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; } } outAsync.attachCollocatedObserver(_adapter, 0); if(invokeNum > 0) { _adapter.getThreadPool().dispatch(() => { if(sentAsync(outAsync)) { invokeAll(outAsync.getOs(), 0, invokeNum, true); } }, null); sentCallback = null; return false; } else { sentCallback = outAsync.sent(); return true; } }
public bool sendAsyncRequest(OutgoingAsyncBase outAsync, out Ice.AsyncCallback sentCallback) { return outAsync.invokeCollocated(this, out sentCallback); }
private bool sentAsync(OutgoingAsyncBase outAsync) { lock(this) { if(!_sendAsyncRequests.Remove(outAsync)) { return false; // The request timed-out. } if(!outAsync.sent()) { return true; } } outAsync.invokeSent(); return true; }
public override void HandleInvokeResponse(bool ok, OutgoingAsyncBase outgoing) => SetResult(((ProxyOutgoingAsyncBase)outgoing).ResponseFrame !);
public override void HandleInvokeResponse(bool ok, OutgoingAsyncBase og) => SetResult(new IncomingResponseFrame(ok ? ReplyStatus.OK : ReplyStatus.UserException, og.GetIs()));
internal Request(OutgoingAsyncBase outAsync) { this.outAsync = outAsync; }
public bool invokeAsyncRequest(OutgoingAsyncBase outAsync, int batchRequestNum, bool synchronous, out Ice.AsyncCallback sentCallback) { // // Increase the direct count to prevent the thread pool from being destroyed before // invokeAll is called. This will also throw if the object adapter has been deactivated. // _adapter.incDirectCount(); int requestId = 0; try { lock(this) { outAsync.cancelable(this); // This will throw if the request is canceled if(_response) { requestId = ++_requestId; _asyncRequests.Add(requestId, outAsync); } _sendAsyncRequests.Add(outAsync, requestId); } } catch(System.Exception) { _adapter.decDirectCount(); throw; } outAsync.attachCollocatedObserver(_adapter, requestId); if(synchronous) { // // Treat this collocated call as if it is a synchronous invocation. // if(_reference.getInvocationTimeout() > 0 || !_response) { // Don't invoke from the user thread, invocation timeouts wouldn't work otherwise. _adapter.getThreadPool().dispatch(() => { if(sentAsync(outAsync)) { invokeAll(outAsync.getOs(), requestId, batchRequestNum); } }, null); } else if(_dispatcher) { _adapter.getThreadPool().dispatchFromThisThread(() => { if(sentAsync(outAsync)) { invokeAll(outAsync.getOs(), requestId, batchRequestNum); } }, null); } else // Optimization: directly call invokeAll if there's no dispatcher. { if(sentAsync(outAsync)) { invokeAll(outAsync.getOs(), requestId, batchRequestNum); } } sentCallback = null; } else { _adapter.getThreadPool().dispatch(() => { if(sentAsync(outAsync)) { invokeAll(outAsync.getOs(), requestId, batchRequestNum); } }, null); sentCallback = null; } return false; }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { Debug.Assert(_outAsync == outAsync); if(_retryQueue.cancel(this)) { if(_instance.traceLevels().retry >= 1) { _instance.initializationData().logger.trace(_instance.traceLevels().retryCat, string.Format("operation retry canceled\n{0}", ex)); } if(_outAsync.exception(ex)) { _outAsync.invokeExceptionAsync(); } } }