Author: kgiusti Date: Fri Mar 30 16:25:21 2012 New Revision: 1307508 URL: http://svn.apache.org/viewvc?rev=1307508&view=rev Log: QPID-3920: merge fix from trunk.
Modified: qpid/branches/0.16/qpid/cpp/src/qpid/framing/ (props changed) qpid/branches/0.16/qpid/cpp/src/qpid/framing/FieldTable.cpp Propchange: qpid/branches/0.16/qpid/cpp/src/qpid/framing/ ------------------------------------------------------------------------------ --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Mar 30 16:25:21 2012 @@ -0,0 +1,8 @@ +/qpid/branches/0.5.x-dev/qpid/cpp/src/qpid/framing:892761,894875 +/qpid/branches/0.6-release-windows-installer/cpp/src/qpid/framing:926803 +/qpid/branches/0.6-release-windows-installer/qpid/cpp/src/qpid/framing:926803,927233 +/qpid/branches/QPID-2519/cpp/src/qpid/framing:1072051-1079078 +/qpid/branches/java-network-refactor/qpid/cpp/src/qpid/framing:805429-825319 +/qpid/branches/qpid-2935/qpid/cpp/src/qpid/framing:1061302-1072333 +/qpid/branches/qpid-3346/qpid/cpp/src/qpid/framing:1144319-1179855 +/qpid/trunk/qpid/cpp/src/qpid/framing:1306434 Modified: qpid/branches/0.16/qpid/cpp/src/qpid/framing/FieldTable.cpp URL: http://svn.apache.org/viewvc/qpid/branches/0.16/qpid/cpp/src/qpid/framing/FieldTable.cpp?rev=1307508&r1=1307507&r2=1307508&view=diff ============================================================================== --- qpid/branches/0.16/qpid/cpp/src/qpid/framing/FieldTable.cpp (original) +++ qpid/branches/0.16/qpid/cpp/src/qpid/framing/FieldTable.cpp Fri Mar 30 16:25:21 2012 @@ -54,11 +54,14 @@ FieldTable::FieldTable() : { } -FieldTable::FieldTable(const FieldTable& ft) : - cachedBytes(ft.cachedBytes), - cachedSize(ft.cachedSize), - newBytes(ft.newBytes) +FieldTable::FieldTable(const FieldTable& ft) { + ScopedLock<Mutex> l(ft.lock); // lock _source_ FieldTable + + cachedBytes = ft.cachedBytes; + cachedSize = ft.cachedSize; + newBytes = ft.newBytes; + // Only copy the values if we have no raw data // - copying the map is expensive and we can // reconstruct it if necessary from the raw data @@ -251,6 +254,7 @@ bool FieldTable::getDouble(const std::st //} void FieldTable::encode(Buffer& buffer) const { + ScopedLock<Mutex> l(lock); // If we've still got the input field table // we can just copy it directly to the output if (cachedBytes) { @@ -264,7 +268,6 @@ void FieldTable::encode(Buffer& buffer) i->second->encode(buffer); } // Now create raw bytes in case we are used again - ScopedLock<Mutex> l(lock); cachedSize = buffer.getPosition() - p; cachedBytes = boost::shared_array<uint8_t>(new uint8_t[cachedSize]); buffer.setPosition(p); @@ -283,6 +286,7 @@ void FieldTable::decode(Buffer& buffer){ if ((available < len) || (available < 4)) throw IllegalArgumentException(QPID_MSG("Not enough data for field table.")); } + ScopedLock<Mutex> l(lock); // Throw away previous stored values values.clear(); // Copy data into our buffer @@ -321,6 +325,7 @@ void FieldTable::realDecode() const void FieldTable::flushRawCache() { + ScopedLock<Mutex> l(lock); // We can only flush the cache if there are no cached bytes to decode assert(newBytes==false); // Avoid recreating shared array unless we actually have one. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org