Пример #1
0
EventableDescriptor::~EventableDescriptor()
{
	if (EventCallback && bCallbackUnbind)
		(*EventCallback)(GetBinding().c_str(), EM_CONNECTION_UNBOUND, NULL, UnbindReasonCode);
	StopProxy();
	Close();
}
Пример #2
0
void mtsManagerProxyClient::OnServerDisconnect(const Ice::Exception & ex)
{
    // Multiple proxy threads can detect server disconnect
    static osaCriticalSection cs;

    cs.Enter();

    if (!IsActiveProxy() || !ProxyOwner->IsGCMActive()) {
        cs.Leave();
        return; // already detected disconnection
    }

    // Ice - ConnectionLostException - forceful closure by peer
    // Ice - ForcedCloseConnectionException - after forceful closure by peer
    CMN_LOG_CLASS_RUN_WARNING << ex << std::endl;
    CMN_LOG_CLASS_RUN_ERROR << "Process \"" << ProxyOwner->GetProcessName() 
        << "\" detected GLOBAL COMPONENT MANAGER DISCONNECTION" << std::endl;

    StopProxy();

    // GCM has been disconnected
    ProxyOwner->SetGCMConnected(false);

    cs.Leave();
}
Пример #3
0
mtsManagerProxyClient::~mtsManagerProxyClient()
{
    StopProxy();

#if IMPROVE_ICE_THREADING
    delete IceThreadInitEvent;
#endif
}
Пример #4
0
void EventableDescriptor::StartProxy(const char *to)
{
	EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (to));
	if (ed) {
		StopProxy();
		ProxyTarget = strdup(to);
		return;
	}
	throw std::runtime_error ("Tried to proxy to an invalid descriptor");
}
Пример #5
0
void EventableDescriptor::_GenericInboundDispatch(const char *buf, int size)
{
	assert(EventCallback);

	if (!ProxyTarget)
		(*EventCallback)(GetBinding().c_str(), EM_CONNECTION_READ, buf, size);
	else if (ConnectionDescriptor::SendDataToConnection(ProxyTarget, buf, size) == -1) {
		(*EventCallback)(GetBinding().c_str(), EM_PROXY_TARGET_UNBOUND, NULL, 0);
		StopProxy();
	}
}
Пример #6
0
void EventableDescriptor::StartProxy(const unsigned long to, const unsigned long bufsize, const unsigned long length)
{
	EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (to));
	if (ed) {
		StopProxy();
		ProxyTarget = ed;
		BytesToProxy = length;
		ed->SetProxiedFrom(this, bufsize);
		return;
	}
	throw std::runtime_error ("Tried to proxy to an invalid descriptor");
}
Пример #7
0
EventableDescriptor::~EventableDescriptor()
{
	if (NextHeartbeat)
		MyEventMachine->ClearHeartbeat(NextHeartbeat);
	if (EventCallback && bCallbackUnbind)
		(*EventCallback)(GetBinding(), EM_CONNECTION_UNBOUND, NULL, UnbindReasonCode);
	if (ProxiedFrom) {
		(*EventCallback)(ProxiedFrom->GetBinding(), EM_PROXY_TARGET_UNBOUND, NULL, 0);
		ProxiedFrom->StopProxy();
	}
	StopProxy();
	Close();
}
Пример #8
0
void EventableDescriptor::_GenericInboundDispatch(const char *buf, int size)
{
	assert(EventCallback);

	if (ProxyTarget) {
		if (BytesToProxy > 0) {
			unsigned long proxied = std::min(BytesToProxy, (unsigned long) size);
			ProxyTarget->SendOutboundData(buf, proxied);
			BytesToProxy -= proxied;
			if (BytesToProxy == 0) {
				StopProxy();
				(*EventCallback)(GetBinding(), EM_PROXY_COMPLETED, NULL, 0);
				if (proxied < size) {
					(*EventCallback)(GetBinding(), EM_CONNECTION_READ, buf + proxied, size - proxied);
				}
			}
		} else {
			ProxyTarget->SendOutboundData(buf, size);
		}
	} else {
		(*EventCallback)(GetBinding(), EM_CONNECTION_READ, buf, size);
	}
}