Skip to content

Commit

Permalink
Enqueued WriteReadyCb results in accessing a deleted AgentDnsXmppChan…
Browse files Browse the repository at this point in the history
…nel object.

We need to UnRegisterWriteReady when the object is deleted.

Change-Id: I1f1f39635f792327f91426d728ab70665bcaec94
Closes-Bug:1531556
Closes-Bug:1547735
  • Loading branch information
nipak committed Feb 25, 2016
1 parent 37d5ed1 commit 3c69334
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bgp/test/bgp_xmpp_channel_test.cc
Expand Up @@ -34,6 +34,7 @@ class XmppChannelMock : public XmppChannel {
}
MOCK_METHOD2(RegisterReceive, void(xmps::PeerId, ReceiveCb));
MOCK_METHOD1(UnRegisterReceive, void(xmps::PeerId));
MOCK_METHOD1(UnRegisterWriteReady, void(xmps::PeerId));
std::string ToString() const { return string("fake"); }
std::string StateName() const { return string("Established"); }

Expand Down
1 change: 1 addition & 0 deletions src/bgp/test/bgp_xmpp_parse_test.cc
Expand Up @@ -27,6 +27,7 @@ class XmppChannelMock : public XmppChannel {
}
void RegisterReceive(xmps::PeerId id, ReceiveCb callback) { }
void UnRegisterReceive(xmps::PeerId id) { }
void UnRegisterWriteReady(xmps::PeerId id) { }
string ToString() const { return string("fake"); }
string StateName() const { return string("Established"); }

Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/controller/controller_dns.cc
Expand Up @@ -30,6 +30,7 @@ AgentDnsXmppChannel::AgentDnsXmppChannel(Agent *agent,
AgentDnsXmppChannel::~AgentDnsXmppChannel() {
if (channel_) {
channel_->UnRegisterReceive(xmps::DNS);
channel_->UnRegisterWriteReady(xmps::DNS);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/controller/controller_ifmap.cc
Expand Up @@ -36,6 +36,7 @@ AgentIfMapXmppChannel::AgentIfMapXmppChannel(Agent *agent, XmppChannel *channel,

AgentIfMapXmppChannel::~AgentIfMapXmppChannel() {
channel_->UnRegisterReceive(xmps::CONFIG);
channel_->UnRegisterWriteReady(xmps::CONFIG);
}

uint64_t AgentIfMapXmppChannel::NewSeqNumber() {
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/controller/controller_peer.cc
Expand Up @@ -85,6 +85,7 @@ AgentXmppChannel::~AgentXmppChannel() {
BgpPeer *bgp_peer = bgp_peer_id_.get();
assert(bgp_peer == NULL);
channel_->UnRegisterReceive(xmps::BGP);
channel_->UnRegisterWriteReady(xmps::BGP);
}

InetUnicastAgentRouteTable *AgentXmppChannel::PrefixToRouteTable
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/test/test_cmn_util.h
Expand Up @@ -398,6 +398,7 @@ class XmppChannelMock : public XmppChannel {
void Close() { }
MOCK_METHOD2(RegisterReceive, void(xmps::PeerId, ReceiveCb));
MOCK_METHOD1(UnRegisterReceive, void(xmps::PeerId));
MOCK_METHOD1(UnRegisterWriteReady, void(xmps::PeerId));
std::string ToString() const { return string("fake"); }
std::string StateName() const { return string("Established"); }

Expand Down
1 change: 1 addition & 0 deletions src/xmpp/xmpp_channel.h
Expand Up @@ -48,6 +48,7 @@ class XmppChannel {
virtual void RegisterReceive(xmps::PeerId, ReceiveCb) = 0;
virtual void UnRegisterReceive(xmps::PeerId) = 0;
virtual void RegisterRxMessageTraceCallback(RxMessageTraceCb cb) = 0;
virtual void UnRegisterWriteReady(xmps::PeerId id) = 0;
virtual void Close() = 0;
virtual std::string ToString() const = 0;
virtual std::string StateName() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/xmpp/xmpp_channel_mux.h
Expand Up @@ -49,6 +49,7 @@ class XmppChannelMux : public XmppChannel {

virtual void ProcessXmppMessage(const XmppStanza::XmppMessage *msg);
void WriteReady(const boost::system::error_code &ec);
virtual void UnRegisterWriteReady(xmps::PeerId id);

void HandleStateEvent(xmsm::XmState state);

Expand All @@ -63,7 +64,6 @@ class XmppChannelMux : public XmppChannel {

private:
void RegisterWriteReady(xmps::PeerId, SendReadyCb);
void UnRegisterWriteReady(xmps::PeerId id);

typedef std::map<xmps::PeerId, SendReadyCb> WriteReadyCbMap;
typedef std::map<xmps::PeerId, ReceiveCb> ReceiveCbMap;
Expand Down

0 comments on commit 3c69334

Please sign in to comment.