Protocol should hang onto shared pointer for protection but always use underlying raw pointer
Reviewed By: aditya
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664982 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h
index 39ee39e..2ad5a57 100644
--- a/lib/cpp/src/protocol/TProtocol.h
+++ b/lib/cpp/src/protocol/TProtocol.h
@@ -283,23 +283,26 @@
}
inline shared_ptr<TTransport> getTransport() {
- return trans_;
+ return ptrans_;
}
// TODO: remove these two calls, they are for backwards
// compatibility
inline shared_ptr<TTransport> getInputTransport() {
- return trans_;
+ return ptrans_;
}
inline shared_ptr<TTransport> getOutputTransport() {
- return trans_;
+ return ptrans_;
}
protected:
- TProtocol(shared_ptr<TTransport> trans):
- trans_(trans) {}
+ TProtocol(shared_ptr<TTransport> ptrans):
+ ptrans_(ptrans) {
+ trans_ = ptrans.get();
+ }
- shared_ptr<TTransport> trans_;
+ shared_ptr<TTransport> ptrans_;
+ TTransport* trans_;
private:
TProtocol() {}