Re-delegate services after config changes.

This commit is contained in:
Gunnar Beutner 2012-06-27 10:59:08 +02:00
parent a9d865c94f
commit 6f9342a261
4 changed files with 16 additions and 9 deletions

View File

@ -317,6 +317,9 @@ void Socket::ReadThreadProc(void)
lock.lock();
if (GetFD() == INVALID_SOCKET)
return;
if (rc < 0) {
HandleSocketError(SocketException("select() failed", GetError()));
return;
@ -362,6 +365,9 @@ void Socket::WriteThreadProc(void)
lock.lock();
if (GetFD() == INVALID_SOCKET)
return;
if (rc < 0) {
HandleSocketError(SocketException("select() failed", GetError()));
return;

View File

@ -33,21 +33,12 @@ public:
typedef shared_ptr<Socket> Ptr;
typedef weak_ptr<Socket> WeakPtr;
//typedef list<Socket::WeakPtr> CollectionType;
//static Socket::CollectionType Sockets;
~Socket(void);
//boost::signal<void (const Socket::Ptr&)> OnReadable;
//boost::signal<void (const Socket::Ptr&)> OnWritable;
//boost::signal<void (const Socket::Ptr&)> OnException;
boost::signal<void (const Socket::Ptr&, const std::exception&)> OnError;
boost::signal<void (const Socket::Ptr&)> OnClosed;
virtual void Start(void);
//virtual void Stop(void);
void Close(void);

View File

@ -30,6 +30,7 @@ string DelegationComponent::GetName(void) const
void DelegationComponent::Start(void)
{
m_AllServices = boost::make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service"));
m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::ObjectCommittedHandler, this, _2));
m_AllServices->Start();
m_DelegationTimer = boost::make_shared<Timer>();
@ -55,6 +56,14 @@ void DelegationComponent::Stop(void)
mgr->UnregisterEndpoint(m_DelegationEndpoint);
}
void DelegationComponent::ObjectCommittedHandler(const ConfigObject::Ptr& object)
{
Service service(object);
/* object was updated, clear its checker to make sure it's re-delegated by the delegation timer */
service.SetChecker("");
}
void DelegationComponent::AssignService(const Endpoint::Ptr& checker, const Service& service)
{
RequestMessage request;

View File

@ -41,6 +41,7 @@ private:
void NewEndpointHandler(const Endpoint::Ptr& endpoint);
void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
void ObjectCommittedHandler(const ConfigObject::Ptr& object);
void DelegationTimerHandler(void);
vector<Endpoint::Ptr> GetCheckerCandidates(const Service& service) const;