RequestHandlerPtr ConnectionRequestHandler::update(const RequestHandlerPtr& previousHandler, const RequestHandlerPtr& newHandler) { assert(previousHandler); try { if(previousHandler.get() == this) { return newHandler; } else if(previousHandler->getConnection() == _connection) { // // If both request handlers point to the same connection, we also // update the request handler. See bug ICE-5489 for reasons why // this can be useful. // return newHandler; } } catch(const Ice::Exception&) { // Ignore. } return this; }
ConnectionPtr IceProxy::Ice::Object::ice_getConnection() { InvocationObserver observer(this, ice_getConnection_name, ::Ice::noExplicitContext); int cnt = 0; while(true) { RequestHandlerPtr handler; try { handler = __getRequestHandler(); return handler->waitForConnection(); // Wait for the connection to be established. } catch(const IceInternal::RetryException&) { __updateRequestHandler(handler, 0); // Clear request handler and retry. } catch(const Exception& ex) { try { int interval = __handleException(ex, handler, ICE_ENUM(OperationMode, Idempotent), false, cnt); observer.retried(); if(interval > 0) { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(interval)); } } catch(const Exception& exc) { observer.failed(exc.ice_id()); throw; } } } }
RequestHandlerPtr ConnectRequestHandler::update(const RequestHandlerPtr& previousHandler, const RequestHandlerPtr& newHandler) { return previousHandler.get() == this ? newHandler : ICE_SHARED_FROM_THIS; }
void FlushBatch::invoke() { assert(_proxy || _connection); if(_connection) { if(_connection->flushBatchRequests(this)) { return; } Monitor<Mutex>::Lock sync(_monitor); while(!_exception.get() && !_sent) { _monitor.wait(); } if(_exception.get()) { _exception->ice_throw(); } return; } RequestHandlerPtr handler; try { handler = _proxy->__getRequestHandler(); if(handler->sendRequest(this)) { return; } bool timedOut = false; { Monitor<Mutex>::Lock sync(_monitor); int timeout = _proxy->__reference()->getInvocationTimeout(); if(timeout > 0) { Time now = Time::now(Time::Monotonic); Time deadline = now + Time::milliSeconds(timeout); while(!_exception.get() && !_sent && !timedOut) { _monitor.timedWait(deadline - now); if(!_exception.get() && !_sent) { now = Time::now(Time::Monotonic); timedOut = now >= deadline; } } } else { while(!_exception.get() && !_sent) { _monitor.wait(); } } } if(timedOut) { Ice::InvocationTimeoutException ex(__FILE__, __LINE__); handler->requestCanceled(this, ex); // // Wait for the exception to propagate. It's possible the request handler ignores // the timeout if there was a failure shortly before requestTimedOut got called. // In this case, the exception should be set on the Outgoing. // Monitor<Mutex>::Lock sync(_monitor); while(!_exception.get() && !_sent) { _monitor.wait(); } } if(_exception.get()) { _exception->ice_throw(); } } catch(const RetryException& ex) { _proxy->__setRequestHandler(handler, 0); // Clear request handler ex.get()->ice_throw(); // Throw to notify the user that batch requests were potentially lost. } catch(const Ice::Exception& ex) { _proxy->__setRequestHandler(handler, 0); // Clear request handler _observer.failed(ex.ice_name()); throw; // Throw to notify the user that batch requests were potentially lost. } }
RequestHandlerPtr CollocatedRequestHandler::update(const RequestHandlerPtr& previousHandler, const RequestHandlerPtr& newHandler) { return previousHandler.get() == this ? newHandler : this; }
RequestHandlerPtr CollocatedRequestHandler::update(const RequestHandlerPtr& previousHandler, const RequestHandlerPtr& newHandler) { return previousHandler.get() == this ? newHandler : shared_from_this(); }