private void flushRequests() { lock (this) { Debug.Assert(_connection != null && !_initialized); // // We set the _flushing flag to true to prevent any additional queuing. Callers // might block for a little while as the queued requests are being sent but this // shouldn't be an issue as the request sends are non-blocking. // _flushing = true; } Ice.LocalException exception = null; foreach (ProxyOutgoingAsyncBase outAsync in _requests) { try { if ((outAsync.invokeRemote(_connection, _compress, _response) & OutgoingAsyncBase.AsyncStatusInvokeSentCallback) != 0) { outAsync.invokeSentAsync(); } } catch (RetryException ex) { exception = ex.get(); // Remove the request handler before retrying. _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); outAsync.retryException(ex.get()); } catch (Ice.LocalException ex) { exception = ex; if (outAsync.exception(ex)) { outAsync.invokeExceptionAsync(); } } } _requests.Clear(); // // If we aren't caching the connection, don't bother creating a // connection request handler. Otherwise, update the proxies // request handler to use the more efficient connection request // handler. // if (_reference.getCacheConnection() && exception == null) { _requestHandler = new ConnectionRequestHandler(_reference, _connection, _compress); foreach (Ice.ObjectPrxHelperBase prx in _proxies) { prx.updateRequestHandler__(this, _requestHandler); } } lock (this) { Debug.Assert(!_initialized); _exception = exception; _initialized = _exception == null; _flushing = false; // // Only remove once all the requests are flushed to // guarantee serialization. // _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); _proxies.Clear(); _proxy = null; // Break cyclic reference count. Monitor.PulseAll(this); } }
private void flushRequests() { lock(this) { Debug.Assert(_connection != null && !_initialized); while(_batchRequestInProgress) { System.Threading.Monitor.Wait(this); } // // We set the _flushing flag to true to prevent any additional queuing. Callers // might block for a little while as the queued requests are being sent but this // shouldn't be an issue as the request sends are non-blocking. // _flushing = true; } LinkedListNode<Request> p = _requests.First; // _requests is immutable when _flushing = true Ice.LocalException exception = null; while(p != null) { Request request = p.Value; try { if(request.os != null) { BasicStream os = new BasicStream(request.os.instance(), Ice.Util.currentProtocolEncoding); _connection.prepareBatchRequest(os); try { request.os.pos(0); os.writeBlob(request.os.readBlob(request.os.size())); } catch(Ice.LocalException) { _connection.abortBatchRequest(); throw; } _connection.finishBatchRequest(os, _compress); } else if(request.outAsync.send(_connection, _compress, _response, out request.sentCallback)) { if(request.sentCallback != null) { request.outAsync.invokeSentAsync(request.sentCallback); } } } catch(RetryException ex) { exception = ex.get(); try { // Remove the request handler before retrying. _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); } catch(Ice.CommunicatorDestroyedException) { // Ignore } request.outAsync.retryException(ex.get()); } catch(Ice.LocalException ex) { exception = ex; Ice.AsyncCallback cb = request.outAsync.completed(ex); if(cb != null) { request.outAsync.invokeCompletedAsync(cb); } } LinkedListNode<Request> tmp = p; p = p.Next; _requests.Remove(tmp); } // // If we aren't caching the connection, don't bother creating a // connection request handler. Otherwise, update the proxies // request handler to use the more efficient connection request // handler. // if(_reference.getCacheConnection() && exception == null) { _connectionRequestHandler = new ConnectionRequestHandler(_reference, _connection, _compress); foreach(Ice.ObjectPrxHelperBase prx in _proxies) { prx.setRequestHandler__(this, _connectionRequestHandler); } } lock(this) { Debug.Assert(!_initialized); _exception = exception; _initialized = _exception == null; _flushing = false; try { // // Only remove once all the requests are flushed to // guarantee serialization. // _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); } catch(Ice.CommunicatorDestroyedException) { // Ignore } _proxies.Clear(); _proxy = null; // Break cyclic reference count. System.Threading.Monitor.PulseAll(this); } }
private void flushRequests() { lock(this) { Debug.Assert(_connection != null && !_initialized); // // We set the _flushing flag to true to prevent any additional queuing. Callers // might block for a little while as the queued requests are being sent but this // shouldn't be an issue as the request sends are non-blocking. // _flushing = true; } Ice.LocalException exception = null; foreach(ProxyOutgoingAsyncBase outAsync in _requests) { try { Ice.AsyncCallback sentCallback = null; if(outAsync.invokeRemote(_connection, _compress, _response, out sentCallback)) { if(sentCallback != null) { outAsync.invokeSentAsync(sentCallback); } } } catch(RetryException ex) { exception = ex.get(); // Remove the request handler before retrying. _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); outAsync.retryException(ex.get()); } catch(Ice.LocalException ex) { exception = ex; Ice.AsyncCallback cb = outAsync.completed(ex); if(cb != null) { outAsync.invokeCompletedAsync(cb); } } } _requests.Clear(); // // If we aren't caching the connection, don't bother creating a // connection request handler. Otherwise, update the proxies // request handler to use the more efficient connection request // handler. // if(_reference.getCacheConnection() && exception == null) { _requestHandler = new ConnectionRequestHandler(_reference, _connection, _compress); foreach(Ice.ObjectPrxHelperBase prx in _proxies) { prx.updateRequestHandler__(this, _requestHandler); } } lock(this) { Debug.Assert(!_initialized); _exception = exception; _initialized = _exception == null; _flushing = false; // // Only remove once all the requests are flushed to // guarantee serialization. // _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); _proxies.Clear(); _proxy = null; // Break cyclic reference count. System.Threading.Monitor.PulseAll(this); } }
private void FlushRequests() { lock (this) { Debug.Assert(_connection != null && !_initialized); // // We set the _flushing flag to true to prevent any additional queuing. Callers // might block for a little while as the queued requests are being sent but this // shouldn't be an issue as the request sends are non-blocking. // _flushing = true; } System.Exception?exception = null; foreach (ProxyOutgoingAsyncBase outAsync in _requests) { try { outAsync.InvokeRemote(_connection, _compress, !outAsync.IsOneway); } catch (RetryException ex) { exception = ex.InnerException; // Remove the request handler before retrying. _reference.Communicator.RemoveConnectRequestHandler(_reference, this); outAsync.RetryException(); } catch (System.Exception ex) { exception = ex; if (outAsync.Exception(ex)) { Task.Run(outAsync.InvokeException); } } } _requests.Clear(); // // If we aren't caching the connection, don't bother creating a // connection request handler. Otherwise, update the proxies // request handler to use the more efficient connection request // handler. // if (_reference.IsConnectionCached && exception == null) { _requestHandler = new ConnectionRequestHandler(_connection, _compress); if (_referenceList != null) { foreach (var reference in _referenceList) { reference.UpdateRequestHandler(this, _requestHandler); } } } lock (this) { Debug.Assert(!_initialized); _exception = exception; _initialized = _exception == null; _flushing = false; // // Only remove once all the requests are flushed to // guarantee serialization. // _reference.Communicator.RemoveConnectRequestHandler(_reference, this); _referenceList = null; Monitor.PulseAll(this); } }