diff --git a/base/socket.cpp b/base/socket.cpp index 756255d63..97b46c049 100644 --- a/base/socket.cpp +++ b/base/socket.cpp @@ -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; diff --git a/base/socket.h b/base/socket.h index c499e5c4a..7878a8ddb 100644 --- a/base/socket.h +++ b/base/socket.h @@ -33,21 +33,12 @@ public: typedef shared_ptr Ptr; typedef weak_ptr WeakPtr; - //typedef list CollectionType; - - //static Socket::CollectionType Sockets; - ~Socket(void); - //boost::signal OnReadable; - //boost::signal OnWritable; - //boost::signal OnException; - boost::signal OnError; boost::signal OnClosed; virtual void Start(void); - //virtual void Stop(void); void Close(void); diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp index 6e763419d..95dad7f9f 100644 --- a/components/delegation/delegationcomponent.cpp +++ b/components/delegation/delegationcomponent.cpp @@ -30,6 +30,7 @@ string DelegationComponent::GetName(void) const void DelegationComponent::Start(void) { m_AllServices = boost::make_shared(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service")); + m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::ObjectCommittedHandler, this, _2)); m_AllServices->Start(); m_DelegationTimer = boost::make_shared(); @@ -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; diff --git a/components/delegation/delegationcomponent.h b/components/delegation/delegationcomponent.h index dea7ce26c..65e573e44 100644 --- a/components/delegation/delegationcomponent.h +++ b/components/delegation/delegationcomponent.h @@ -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 GetCheckerCandidates(const Service& service) const;