mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
Check 'breaker_list' before locking. (#1767)
* Check breaker_list before locking. * Remove 'pre_select'.
This commit is contained in:
@@ -61,7 +61,6 @@ public:
|
||||
protected:
|
||||
virtual void dispatch();
|
||||
virtual SubTask *done();
|
||||
void set_has_next() { has_next_ = true; }
|
||||
|
||||
private:
|
||||
void thread_dns_callback(void *thrd_dns_task);
|
||||
|
||||
@@ -144,23 +144,6 @@ void WFSGResolverTask::dispatch()
|
||||
return;
|
||||
}
|
||||
|
||||
if (sg_->pre_select_)
|
||||
{
|
||||
WFConditional *cond = sg_->pre_select_(this);
|
||||
if (cond)
|
||||
{
|
||||
series_of(this)->push_front(cond);
|
||||
this->set_has_next();
|
||||
this->subtask_done();
|
||||
return;
|
||||
}
|
||||
else if (this->state != WFT_STATE_UNDEFINED)
|
||||
{
|
||||
this->subtask_done();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (sg_->select(ns_params_.uri, tracing, &addr))
|
||||
{
|
||||
auto *tracing_data = (WFServiceGovernance::TracingData *)tracing->data;
|
||||
@@ -324,10 +307,12 @@ void WFServiceGovernance::check_breaker_locked(int64_t cur_time)
|
||||
|
||||
void WFServiceGovernance::check_breaker()
|
||||
{
|
||||
pthread_mutex_lock(&this->breaker_lock);
|
||||
if (!list_empty(&this->breaker_list))
|
||||
{
|
||||
pthread_mutex_lock(&this->breaker_lock);
|
||||
this->check_breaker_locked(GET_CURRENT_SECOND);
|
||||
pthread_mutex_unlock(&this->breaker_lock);
|
||||
pthread_mutex_unlock(&this->breaker_lock);
|
||||
}
|
||||
}
|
||||
|
||||
void WFServiceGovernance::try_clear_breaker()
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include "URIParser.h"
|
||||
#include "EndpointParams.h"
|
||||
#include "WFNameService.h"
|
||||
@@ -123,14 +122,6 @@ public:
|
||||
|
||||
static bool in_select_history(WFNSTracing *tracing, EndpointAddress *addr);
|
||||
|
||||
public:
|
||||
using pre_select_t = std::function<WFConditional *(WFRouterTask *)>;
|
||||
|
||||
void set_pre_select(pre_select_t pre_select)
|
||||
{
|
||||
pre_select_ = std::move(pre_select);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool select(const ParsedURI& uri, WFNSTracing *tracing,
|
||||
EndpointAddress **addr);
|
||||
@@ -156,7 +147,6 @@ private:
|
||||
struct list_head breaker_list;
|
||||
pthread_mutex_t breaker_lock;
|
||||
unsigned int mttr_seconds;
|
||||
pre_select_t pre_select_;
|
||||
|
||||
protected:
|
||||
virtual EndpointAddress *first_strategy(const ParsedURI& uri,
|
||||
|
||||
Reference in New Issue
Block a user