Skip to content

Commit

Permalink
Reuse ifmap xmpp message string for tracing
Browse files Browse the repository at this point in the history
Pass a reference to std:string to SendUpdate so that it can be passed
on to XmppChannel::Send and then on to XmppConnection::Send, which can
now use the provided string (changed via bug number 1607132) instead
of constructing a new one from the data pointer.

Change-Id: If94a1cf63ab07a9ba9703bc5e54a6e177835217b
Partial-Bug: 1602347
  • Loading branch information
Nischal Sheth committed Sep 15, 2016
1 parent 9c364c1 commit d7e1178
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/ifmap/ifmap_encoder.cc
Expand Up @@ -112,8 +112,3 @@ void IFMapMessage::Reset() {
op_type_ = NONE;
Open();
}

const char * IFMapMessage::c_str() const {
assert(!str_.empty());
return str_.c_str();
}
2 changes: 1 addition & 1 deletion src/ifmap/ifmap_encoder.h
Expand Up @@ -25,7 +25,7 @@ class IFMapMessage {
bool IsEmpty();
void Reset();

const char *c_str() const;
const std::string &get_string() const { return str_; }

private:
enum Op {
Expand Down
2 changes: 1 addition & 1 deletion src/ifmap/ifmap_update_sender.cc
Expand Up @@ -262,7 +262,7 @@ void IFMapUpdateSender::SendUpdate(BitSet send_set, BitSet *blocked_set) {
message_->Close();

// Send the string version of the message to the client.
send_result = client->SendUpdate(message_->c_str());
send_result = client->SendUpdate(message_->get_string());

// Keep track of all the clients whose buffers are full.
if (!send_result) {
Expand Down
3 changes: 2 additions & 1 deletion src/ifmap/ifmap_xmpp.cc
Expand Up @@ -113,7 +113,8 @@ IFMapXmppChannel::IFMapSender::IFMapSender(IFMapXmppChannel *parent)

bool IFMapXmppChannel::IFMapSender::SendUpdate(const std::string &msg) {
bool sent = parent_->channel_->Send(
(const uint8_t *)msg.data(), msg.size(), xmps::CONFIG,
reinterpret_cast<const uint8_t *>(msg.data()), msg.size(), &msg,
xmps::CONFIG,
boost::bind(&IFMapXmppChannel::WriteReadyCb, parent_, _1));

if (sent) {
Expand Down

0 comments on commit d7e1178

Please sign in to comment.