summaryrefslogtreecommitdiff
path: root/src/mongo/tools
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-01-15 16:55:36 -0500
committerBenety Goh <benety@mongodb.com>2015-01-15 17:02:32 -0500
commitab47afeb030b42097acede562760c3a2ca785086 (patch)
treec79ca2ec256d6e2593fe937b57a70e0b2ce57e11 /src/mongo/tools
parent85fcc6daad585196ce69f1868f8283e0d92388be (diff)
downloadmongo-ab47afeb030b42097acede562760c3a2ca785086.tar.gz
SERVER-15322 fixed mongosniffer log message
Diffstat (limited to 'src/mongo/tools')
-rw-r--r--src/mongo/tools/sniffer.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/tools/sniffer.cpp b/src/mongo/tools/sniffer.cpp
index 09a5b229107..004bf66467e 100644
--- a/src/mongo/tools/sniffer.cpp
+++ b/src/mongo/tools/sniffer.cpp
@@ -36,6 +36,7 @@
killcursors
*/
+
#include "mongo/platform/basic.h"
#ifdef _WIN32
@@ -78,6 +79,7 @@ using mongo::BSONObj;
using mongo::BufBuilder;
using mongo::DBClientConnection;
using mongo::MemoryMappedFile;
+using std::string;
#define SNAP_LEN 65535
@@ -256,9 +258,12 @@ void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *pa
DbMessage d( m );
- out() << inet_ntoa(ip->ip_src) << ":" << ntohs( tcp->th_sport )
+ // inet_ntoa uses statically allocated buffer.
+ string sourceAddress = inet_ntoa(ip->ip_src);
+ string destinationAddress = inet_ntoa(ip->ip_dst);
+ out() << sourceAddress << ":" << ntohs( tcp->th_sport )
<< ( serverPorts.count( ntohs( tcp->th_dport ) ) ? " -->> " : " <<-- " )
- << inet_ntoa(ip->ip_dst) << ":" << ntohs( tcp->th_dport )
+ << destinationAddress << ":" << ntohs( tcp->th_dport )
<< " " << (d.messageShouldHaveNs() ? d.getns() : "")
<< " " << m.header().getLen() << " bytes "
<< " id:" << hex << m.header().getId() << dec << "\t" << m.header().getId();