From 7cfc47a836ac1f92a80f37acedd048ec3dd19b4e Mon Sep 17 00:00:00 2001 From: Michael Goulish Date: Wed, 30 Mar 2011 19:11:09 +0000 Subject: qpid-3171 The registration of the codec happens on a different thread from the use of the codec. It is possible for the registration to occur after the first attempted use. In my testing, this happened 3% of the time -- 165 times out of 5000 tests -- when using RDMA transport, and 0 times out of 5000 when using TCP. Which is why we didn't notice it earlier. We have a function that tells when we are ready to encode -- CyrusSecurityLayer::canEncode. But it does not check the validity of the codec pointer before using it, so it cores in this situation. I believe simply checking that pointer is probably the best solution. Introducing that check caused the crash not to show up in 10,000 trials. There were also no hangs. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1087047 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp b/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp index 454ce62495..3d868da64b 100644 --- a/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp +++ b/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp @@ -106,7 +106,7 @@ size_t CyrusSecurityLayer::encode(const char* buffer, size_t size) bool CyrusSecurityLayer::canEncode() { - return encrypted || codec->canEncode(); + return codec && (encrypted || codec->canEncode()); } void CyrusSecurityLayer::init(qpid::sys::Codec* c) -- cgit v1.2.1