Skip to content

Commit

Permalink
contrail-collector crash immediately after provisioning
Browse files Browse the repository at this point in the history
root cause:
  To state_machine_, sandesh_connection is owner as scoped_ptr.
  generator as user use state_machine_.get() to access. sandesh
  _connection will deal with connection close message in one core
  but generator will deal with redis message in another core. This
  lead source race condition. We have use mutex lock to protect.
  but mutex is one part of state_machine_ structure, so to
  destructed fucntion of state_machine_, protecting is invalid.
Solution:
  Change scoped_ptr to shared_ptr.

Change-Id: I1756f8dc0cdd1e7b705af9f1650c6bb8b118e212
Partial-Bug: 1755649
  • Loading branch information
ZhiqiangCui committed Mar 30, 2018
1 parent a68a299 commit bbfbb6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions library/cpp/sandesh_connection.cc
Expand Up @@ -99,6 +99,11 @@ SandeshStateMachine *SandeshConnection::state_machine() const {
return state_machine_.get();
}

boost::shared_ptr<SandeshStateMachine>
SandeshConnection::shared_state_machine() const {
return state_machine_;
}

void SandeshConnection::SetAdminState(bool down) {
if (admin_down_ != down) {
admin_down_ = down;
Expand Down
5 changes: 3 additions & 2 deletions library/cpp/sandesh_connection.h
Expand Up @@ -45,6 +45,7 @@ class SandeshConnection {

SandeshSession *session() const;
SandeshStateMachine *state_machine() const;
boost::shared_ptr<SandeshStateMachine> shared_state_machine() const;

std::string StateName() const { return state_machine_->StateName(); }

Expand Down Expand Up @@ -91,8 +92,8 @@ class SandeshConnection {
SandeshSession *session_;
int task_instance_;
int task_id_;
boost::scoped_ptr<SandeshStateMachine> state_machine_;
boost::shared_ptr<SandeshStateMachine> state_machine_;

DISALLOW_COPY_AND_ASSIGN(SandeshConnection);
};

Expand Down

0 comments on commit bbfbb6a

Please sign in to comment.