Skip to content

Commit

Permalink
Run diag timers in Diag task context
Browse files Browse the repository at this point in the history
The diag timer and segment health check timer are running in the ASIO
context and could lead to parallel updates. Changing them to run Agent::Diag
task context.

Change-Id: I393a8f5c811e65ca6eb8970a40447b6426e29388
partial-bug: #1729581
  • Loading branch information
haripk committed Nov 3, 2017
1 parent a329fc9 commit 7f59ec1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/vnsw/agent/diag/diag.cc
Expand Up @@ -30,7 +30,8 @@ DiagEntry::DiagEntry(const std::string &sip, const std::string &dip,
proto_(proto), sport_(sport), dport_(dport),
vrf_name_(vrf_name), diag_table_(diag_table), timeout_(timeout),
timer_(TimerManager::CreateTimer(*(diag_table->agent()->event_manager())->io_service(),
"DiagTimeoutHandler")), max_attempts_(attempts), seq_no_(0) {
"DiagTimeoutHandler", TaskScheduler::GetInstance()->GetTaskId("Agent::Diag"), 0)),
max_attempts_(attempts), seq_no_(0) {
}

DiagEntry::~DiagEntry() {
Expand Down Expand Up @@ -65,10 +66,15 @@ bool DiagEntry::TimerExpiry( uint32_t seq_no) {
RequestTimedOut(seq_no);
if (IsDone()) {
op = new DiagEntryOp(DiagEntryOp::DELETE, this);
} else {
op = new DiagEntryOp(DiagEntryOp::RETRY, this);
diag_table_->Enqueue(op);
return false;
}

if (ResendOnTimerExpiry()) {
SendRequest();
return true;
}
diag_table_->Enqueue(op);

return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/diag/diag.h
Expand Up @@ -36,6 +36,7 @@ class DiagEntry {
bool TimerExpiry(uint32_t seqno);
void RestartTimer();
virtual bool IsDone();
virtual bool ResendOnTimerExpiry() { return true; }
DiagKey GetKey() { return key_;};
uint32_t GetSeqNo() {return seq_no_;};
uint32_t GetMaxAttempts() {return max_attempts_;};
Expand Down
5 changes: 4 additions & 1 deletion src/vnsw/agent/diag/segment_health_check.cc
Expand Up @@ -20,7 +20,8 @@ SegmentHealthCheckPkt::SegmentHealthCheckPkt(HealthCheckInstanceService *svc,
delay_msecs_ = GetDelay(svc);
delay_timer_ = TimerManager::CreateTimer
(*(diag_table->agent()->event_manager())->io_service(),
"SegmentHCDelayTimeoutHandler");
"SegmentHCDelayTimeoutHandler",
TaskScheduler::GetInstance()->GetTaskId("Agent::Diag"), 0);
}


Expand Down Expand Up @@ -48,6 +49,7 @@ int SegmentHealthCheckPkt::GetTimeout(const HealthCheckInstanceService *svc)
}

void SegmentHealthCheckPkt::Retry() {
delay_timer_->Cancel();
delay_timer_->Start(delay_msecs_,
boost::bind(&SegmentHealthCheckPkt::RetryHandler, this));
}
Expand Down Expand Up @@ -132,6 +134,7 @@ void SegmentHealthCheckPkt::RequestTimedOut(uint32_t seqno) {
Notify(FAILURE);
seq_no_ = 0;
}
Retry();
}

void SegmentHealthCheckPkt::HandleReply(DiagPktHandler *handler) {
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/diag/segment_health_check.h
Expand Up @@ -33,6 +33,7 @@ class SegmentHealthCheckPkt: public DiagEntry {
*/
return false;
}
virtual bool ResendOnTimerExpiry() { return false; }
void set_service(HealthCheckInstanceService *svc) {
service_ = svc;
}
Expand Down

0 comments on commit 7f59ec1

Please sign in to comment.