Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ endif()
# Create the thrift C++ library
set(thriftcpp_SOURCES
src/thrift/TApplicationException.cpp
src/thrift/TConfiguration.cpp
src/thrift/TOutput.cpp
src/thrift/TUuid.cpp
src/thrift/async/TAsyncChannel.cpp
Expand Down
1 change: 1 addition & 0 deletions lib/cpp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(OPENSSL_INCLUDES) -I$(srcdir)/src -D__STDC_FOR
# Define the source files for the module

libthrift_la_SOURCES = src/thrift/TApplicationException.cpp \
src/thrift/TConfiguration.cpp \
src/thrift/TOutput.cpp \
src/thrift/TUuid.cpp \
src/thrift/VirtualProfiling.cpp \
Expand Down
1 change: 1 addition & 0 deletions lib/cpp/libthrift.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<ClCompile Include="src\thrift\server\TThreadedServer.cpp" />
<ClCompile Include="src\thrift\server\TThreadPoolServer.cpp" />
<ClCompile Include="src\thrift\TApplicationException.cpp" />
<ClCompile Include="src\thrift\TConfiguration.cpp" />
<ClCompile Include="src\thrift\TOutput.cpp" />
<ClCompile Include="src\thrift\TUuid.cpp" />
<ClCompile Include="src\thrift\transport\SocketCommon.cpp" />
Expand Down
1 change: 1 addition & 0 deletions lib/cpp/libthrift.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<ClCompile Include="src\thrift\TUuid.cpp" />
<ClCompile Include="src\thrift\TOutput.cpp" />
<ClCompile Include="src\thrift\TApplicationException.cpp" />
<ClCompile Include="src\thrift\TConfiguration.cpp" />
<ClCompile Include="src\thrift\transport\TTransportException.cpp">
<Filter>transport</Filter>
</ClCompile>
Expand Down
32 changes: 32 additions & 0 deletions lib/cpp/src/thrift/TConfiguration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include <thrift/TConfiguration.h>

namespace apache {
namespace thrift {

// Binding one of these constants to a reference, as std::make_shared or
// std::min do, needs a definition before C++17.
const int TConfiguration::DEFAULT_MAX_MESSAGE_SIZE;
const int TConfiguration::DEFAULT_MAX_FRAME_SIZE;
const int TConfiguration::DEFAULT_RECURSION_DEPTH;

}
} // apache::thrift
14 changes: 14 additions & 0 deletions lib/cpp/test/TTransportFactoryConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,17 @@ BOOST_AUTO_TEST_CASE(test_framed_transport_default_constructor_initialises_max_f
TFramedTransport wrapped(std::make_shared<TMemoryBuffer>(), config);
BOOST_CHECK_EQUAL(wrapped.getMaxFrameSize(), static_cast<uint32_t>(kMaxFrameSize));
}

// Binding a default to a reference or taking its address needs the library to
// define it. Reading the addresses through volatile pointers keeps an
// optimising compiler from folding the references away (THRIFT-6213).
BOOST_AUTO_TEST_CASE(test_configuration_defaults_are_defined) {
const int* volatile maxMessageSize = &TConfiguration::DEFAULT_MAX_MESSAGE_SIZE;
const int* volatile maxFrameSize = &TConfiguration::DEFAULT_MAX_FRAME_SIZE;
const int* volatile recursionDepth = &TConfiguration::DEFAULT_RECURSION_DEPTH;

const TConfiguration config;
BOOST_CHECK_EQUAL(*maxMessageSize, config.getMaxMessageSize());
BOOST_CHECK_EQUAL(*maxFrameSize, config.getMaxFrameSize());
BOOST_CHECK_EQUAL(*recursionDepth, config.getRecursionLimit());
}
Loading