From 838dd2a60350b0175d81374d7b2718684fa6d933 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 7 Apr 2017 15:50:25 -0400 Subject: [PATCH] common/zipkin_trace: fix blkin_trace_info encoding - encode the same regardless of whether it is compiled in (!) - encode in endian- and struct alignment-safe way. Signed-off-by: Sage Weil --- src/common/zipkin_trace.h | 24 +++++++++++++++++++++++- src/msg/Message.cc | 3 --- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/common/zipkin_trace.h b/src/common/zipkin_trace.h index 94716b4ad97..6d3f02b43e2 100644 --- a/src/common/zipkin_trace.h +++ b/src/common/zipkin_trace.h @@ -13,7 +13,13 @@ #else // !WITH_BLKIN // add stubs for noop Trace and Endpoint -struct blkin_trace_info {}; + +// match the "real" struct +struct blkin_trace_info { + int64_t trace_id; + int64_t span_id; + int64_t parent_span_id; +}; namespace ZTracer { @@ -66,4 +72,20 @@ class Trace { #endif // !WITH_BLKIN +static inline void encode(const blkin_trace_info& b, bufferlist& bl) +{ + ::encode(b.trace_id, bl); + ::encode(b.span_id, bl); + ::encode(b.parent_span_id, bl); +} + +static inline void decode(blkin_trace_info& b, bufferlist::iterator& p) +{ + ::decode(b.trace_id, p); + ::decode(b.span_id, p); + ::decode(b.parent_span_id, p); +} + + + #endif // COMMON_ZIPKIN_TRACE_H diff --git a/src/msg/Message.cc b/src/msg/Message.cc index 62cbcdd33cb..5579e34825a 100644 --- a/src/msg/Message.cc +++ b/src/msg/Message.cc @@ -841,9 +841,6 @@ Message *decode_message(CephContext *cct, int crcflags, return m; } - -WRITE_RAW_ENCODER(blkin_trace_info) - void Message::encode_trace(bufferlist &bl, uint64_t features) const { auto p = trace.get_info(); -- 2.39.5