`make style` applied
diff --git a/build/cmake/DefineCMakeDefaults.cmake b/build/cmake/DefineCMakeDefaults.cmake
index f41673e..7073e8e 100644
--- a/build/cmake/DefineCMakeDefaults.cmake
+++ b/build/cmake/DefineCMakeDefaults.cmake
@@ -26,7 +26,7 @@
# Put the include dirs which are in the source or build tree
# before all other include dirs, so the headers in the sources
-# are prefered over the already installed ones
+# are preferred over the already installed ones
# since cmake 2.4.1
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in
index 8b75e8c..181ea18 100644
--- a/build/cmake/config.h.in
+++ b/build/cmake/config.h.in
@@ -63,7 +63,7 @@
#define SIGNED_RIGHT_SHIFT_IS 1
/* Use *.h extension for parser header file */
-/* TODO: This might now be necessary anymore as it is set onyl for automake < 1.11
+/* TODO: This might now be necessary anymore as it is set only for automake < 1.11
see: aclocal/ac_prog_bison.m4 */
#cmakedefine BISON_USE_PARSER_H_EXTENSION 1
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index 098f63b..dfdd4ef 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -1804,9 +1804,9 @@
indent(f_service_) << function_signature(&implementing_function) << endl;
scope_up(f_service_);
- f_service_ << indent() << "g_return_val_if_fail (" << this->nspace_uc << "IS_" << service_name_uc
- << "_HANDLER (iface), FALSE);" << endl << endl << indent() << "return " << class_name_uc
- << "_GET_CLASS (iface)"
+ f_service_ << indent() << "g_return_val_if_fail (" << this->nspace_uc << "IS_"
+ << service_name_uc << "_HANDLER (iface), FALSE);" << endl << endl << indent()
+ << "return " << class_name_uc << "_GET_CLASS (iface)"
<< "->" << method_name << " (iface, ";
if (!return_type->is_void()) {
diff --git a/compiler/cpp/src/generate/t_cocoa_generator.cc b/compiler/cpp/src/generate/t_cocoa_generator.cc
index e3e1842..a90c937 100644
--- a/compiler/cpp/src/generate/t_cocoa_generator.cc
+++ b/compiler/cpp/src/generate/t_cocoa_generator.cc
@@ -136,9 +136,11 @@
void generate_cocoa_service_client_interface(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_client_async_interface(std::ofstream& out, t_service* tservice);
- void generate_cocoa_service_client_send_function_implementation(ofstream& out, t_function* tfunction);
+ void generate_cocoa_service_client_send_function_implementation(ofstream& out,
+ t_function* tfunction);
void generate_cocoa_service_client_send_function_invocation(ofstream& out, t_function* tfunction);
- void generate_cocoa_service_client_recv_function_implementation(ofstream& out, t_function* tfunction);
+ void generate_cocoa_service_client_recv_function_implementation(ofstream& out,
+ t_function* tfunction);
void generate_cocoa_service_client_implementation(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_client_async_implementation(std::ofstream& out, t_service* tservice);
@@ -1229,7 +1231,7 @@
generate_cocoa_service_helpers(tservice);
generate_cocoa_service_client_implementation(f_impl_, tservice);
generate_cocoa_service_server_implementation(f_impl_, tservice);
- if(async_clients_) {
+ if (async_clients_) {
generate_cocoa_service_async_protocol(f_header_, tservice);
generate_cocoa_service_client_async_interface(f_header_, tservice);
generate_cocoa_service_client_async_implementation(f_impl_, tservice);
@@ -1324,7 +1326,8 @@
* @param tservice The service to generate a protocol definition for
*/
void t_cocoa_generator::generate_cocoa_service_async_protocol(ofstream& out, t_service* tservice) {
- out << "@protocol " << cocoa_prefix_ << tservice->get_name() << "Async" << " <NSObject>" << endl;
+ out << "@protocol " << cocoa_prefix_ << tservice->get_name() << "Async"
+ << " <NSObject>" << endl;
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
@@ -1393,8 +1396,9 @@
out << "@end" << endl << endl;
}
-void t_cocoa_generator::generate_cocoa_service_client_send_function_implementation(ofstream& out,
- t_function* tfunction) {
+void t_cocoa_generator::generate_cocoa_service_client_send_function_implementation(
+ ofstream& out,
+ t_function* tfunction) {
string funname = tfunction->get_name();
t_function send_function(g_type_void,
@@ -1446,8 +1450,9 @@
out << endl;
}
-void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementation(ofstream& out,
- t_function* tfunction) {
+void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementation(
+ ofstream& out,
+ t_function* tfunction) {
t_struct noargs(program_);
t_function recv_function(tfunction->get_returntype(),
string("recv_") + tfunction->get_name(),
@@ -1468,8 +1473,8 @@
// FIXME - could optimize here to reduce creation of temporary objects.
string resultname = function_result_helper_struct_type(tfunction);
- out << indent() << cocoa_prefix_ << resultname << " * result = [[[" << cocoa_prefix_
- << resultname << " alloc] init] autorelease_stub];" << endl;
+ out << indent() << cocoa_prefix_ << resultname << " * result = [[[" << cocoa_prefix_ << resultname
+ << " alloc] init] autorelease_stub];" << endl;
indent(out) << "[result read: inProtocol];" << endl;
indent(out) << "[inProtocol readMessageEnd];" << endl;
@@ -1483,9 +1488,8 @@
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- out << indent() << "if ([result " << (*x_iter)->get_name() << "IsSet]) {" << endl
- << indent() << " @throw [result " << (*x_iter)->get_name() << "];" << endl << indent()
- << "}" << endl;
+ out << indent() << "if ([result " << (*x_iter)->get_name() << "IsSet]) {" << endl << indent()
+ << " @throw [result " << (*x_iter)->get_name() << "];" << endl << indent() << "}" << endl;
}
// If you get here it's an exception, unless a void function
@@ -1508,8 +1512,9 @@
*
* @param tfunction The service to generate an implementation for
*/
-void t_cocoa_generator::generate_cocoa_service_client_send_function_invocation(ofstream& out,
- t_function* tfunction) {
+void t_cocoa_generator::generate_cocoa_service_client_send_function_invocation(
+ ofstream& out,
+ t_function* tfunction) {
t_struct* arg_struct = tfunction->get_arglist();
const vector<t_field*>& fields = arg_struct->get_members();
vector<t_field*>::const_iterator fld_iter;
@@ -1558,7 +1563,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::const_iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-
+
generate_cocoa_service_client_send_function_implementation(out, *f_iter);
if (!(*f_iter)->is_oneway()) {
@@ -1569,7 +1574,7 @@
indent(out) << "- " << function_signature(*f_iter) << endl;
scope_up(out);
generate_cocoa_service_client_send_function_invocation(out, *f_iter);
-
+
out << indent() << "[[outProtocol transport] flush];" << endl;
if (!(*f_iter)->is_oneway()) {
out << indent();
@@ -1592,13 +1597,14 @@
*/
void t_cocoa_generator::generate_cocoa_service_client_async_implementation(ofstream& out,
t_service* tservice) {
- out << "@implementation " << cocoa_prefix_ << tservice->get_name() << "ClientAsync" << endl << endl
- << "- (id) initWithProtocolFactory: (id <TProtocolFactory>) factory "
- "transport: (id <TAsyncTransport>) transport;" << endl;
+ out << "@implementation " << cocoa_prefix_ << tservice->get_name() << "ClientAsync" << endl
+ << endl << "- (id) initWithProtocolFactory: (id <TProtocolFactory>) factory "
+ "transport: (id <TAsyncTransport>) transport;" << endl;
scope_up(out);
out << indent() << "self = [super init];" << endl;
- out << indent() << "inProtocol = [[factory newProtocolOnTransport:transport] retain_stub];" << endl;
+ out << indent() << "inProtocol = [[factory newProtocolOnTransport:transport] retain_stub];"
+ << endl;
out << indent() << "outProtocol = inProtocol;" << endl;
out << indent() << "asyncTransport = transport;" << endl;
out << indent() << "return self;" << endl;
@@ -1609,7 +1615,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::const_iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-
+
generate_cocoa_service_client_send_function_implementation(out, *f_iter);
if (!(*f_iter)->is_oneway()) {
@@ -1625,11 +1631,10 @@
indent_down();
out << indent() << "} @catch(TException * texception) {" << endl;
indent_up();
- out << indent() << "failureBlock(texception);" << endl
- << indent() << "return;" << endl;
+ out << indent() << "failureBlock(texception);" << endl << indent() << "return;" << endl;
indent_down();
indent(out) << "}" << endl;
-
+
out << indent() << "[asyncTransport flush:^{" << endl;
indent_up();
@@ -2719,10 +2724,9 @@
if (!ttype->is_void()) {
response_param = "void (^)(" + type_name(ttype) + ")";
}
- std::string result = "(void) " + tfunction->get_name()
- + argument_list(tfunction->get_arglist())
- + (targlist->get_members().size() ? " response" : "")
- + ": (" + response_param + ") responseBlock "
+ std::string result = "(void) " + tfunction->get_name() + argument_list(tfunction->get_arglist())
+ + (targlist->get_members().size() ? " response" : "") + ": ("
+ + response_param + ") responseBlock "
+ "failure : (TAsyncFailureBlock) failureBlock";
return result;
}
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index 586ab75..d6aad75 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -1719,7 +1719,7 @@
scope_up(f_service_);
t_struct* xs = (*f_iter)->get_xceptions();
- prepare_member_name_mapping(xs,xs->get_members(),resultname);
+ prepare_member_name_mapping(xs, xs->get_members(), resultname);
f_service_ << indent() << "TMessage msg = iprot_.ReadMessageBegin();" << endl << indent()
<< "if (msg.Type == TMessageType.Exception) {" << endl;
@@ -1945,7 +1945,7 @@
if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
f_service_ << indent() << "}";
- prepare_member_name_mapping(xs,xs->get_members(),resultname);
+ prepare_member_name_mapping(xs, xs->get_members(), resultname);
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " "
<< (*x_iter)->get_name() << ") {" << endl;
@@ -2512,11 +2512,10 @@
// current C# generator policy:
// - prop names are always rendered with an Uppercase first letter
// - struct names are used as given
-
-
+
// prevent name conflicts with struct (CS0542 error)
used_member_names.insert(structname);
-
+
// prevent name conflicts with known methods (THRIFT-2942)
used_member_names.insert("Read");
used_member_names.insert("Write");
diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc
index 82340fd..0030d24 100644
--- a/compiler/cpp/src/generate/t_go_generator.cc
+++ b/compiler/cpp/src/generate/t_go_generator.cc
@@ -134,9 +134,9 @@
const string& tstruct_name,
bool is_result = false);
void generate_countsetfields_helper(std::ofstream& out,
- t_struct* tstruct,
- const string& tstruct_name,
- bool is_result = false);
+ t_struct* tstruct,
+ const string& tstruct_name,
+ bool is_result = false);
void generate_go_struct_reader(std::ofstream& out,
t_struct* tstruct,
const string& tstruct_name,
@@ -413,21 +413,22 @@
std::string t_go_generator::camelcase(const std::string& value) const {
std::string value2(value);
std::setlocale(LC_ALL, "C"); // set locale to classic
-
- // as long as we are changing things, let's change _ followed by lowercase to capital and fix common initialisms
+
+ // as long as we are changing things, let's change _ followed by lowercase to capital and fix
+ // common initialisms
for (std::string::size_type i = 1; i < value2.size() - 1; ++i) {
- if (value2[i] == '_'){
+ if (value2[i] == '_') {
if (islower(value2[i + 1])) {
value2.replace(i, 2, 1, toupper(value2[i + 1]));
}
- std::string word = value2.substr(i,value2.find('_', i));
+ std::string word = value2.substr(i, value2.find('_', i));
std::transform(word.begin(), word.end(), word.begin(), ::toupper);
if (commonInitialisms.find(word) != commonInitialisms.end()) {
- value2.replace(i, word.length(), word);
+ value2.replace(i, word.length(), word);
}
}
}
-
+
return value2;
}
@@ -878,16 +879,16 @@
f_types_ << indent() << " " << tenum_name << "_" << iter_name << ' ' << tenum_name << " = "
<< value << endl;
// Dictionaries to/from string names of enums
- to_string_mapping << indent() << " case " << tenum_name << "_" << iter_name
- << ": return \"" << iter_std_name << "\"" << endl;
+ to_string_mapping << indent() << " case " << tenum_name << "_" << iter_name << ": return \""
+ << iter_std_name << "\"" << endl;
if (iter_std_name != escape_string(iter_name)) {
from_string_mapping << indent() << " case \"" << iter_std_name << "\", \""
- << escape_string(iter_name) << "\": return " << tenum_name
- << "_" << iter_name << ", nil " << endl;
+ << escape_string(iter_name) << "\": return " << tenum_name << "_"
+ << iter_name << ", nil " << endl;
} else {
- from_string_mapping << indent() << " case \"" << iter_std_name << "\": return "
- << tenum_name << "_" << iter_name << ", nil " << endl;
+ from_string_mapping << indent() << " case \"" << iter_std_name << "\": return " << tenum_name
+ << "_" << iter_name << ", nil " << endl;
}
}
@@ -1188,9 +1189,8 @@
if (it != (*m_iter)->annotations_.end()) {
gotag = it->second;
}
- indent(out) << publicize((*m_iter)->get_name()) << " " << goType
- << " `thrift:\"" << escape_string((*m_iter)->get_name()) << ","
- << sorted_keys_pos;
+ indent(out) << publicize((*m_iter)->get_name()) << " " << goType << " `thrift:\""
+ << escape_string((*m_iter)->get_name()) << "," << sorted_keys_pos;
if ((*m_iter)->get_req() == t_field::T_REQUIRED) {
out << ",required";
@@ -1248,7 +1248,6 @@
}
}
-
if (tstruct->is_union() && num_setable > 0) {
generate_countsetfields_helper(out, tstruct, tstruct_name, is_result);
}
@@ -1285,8 +1284,7 @@
const string escaped_tstruct_name(escape_string(tstruct->get_name()));
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- const string field_name(
- publicize(escape_string((*f_iter)->get_name())));
+ const string field_name(publicize(escape_string((*f_iter)->get_name())));
if ((*f_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*f_iter)) {
out << indent() << "func (p *" << tstruct_name << ") IsSet" << field_name << "() bool {"
<< endl;
@@ -1316,16 +1314,15 @@
* Generates the CountSetFields helper method for a struct
*/
void t_go_generator::generate_countsetfields_helper(ofstream& out,
- t_struct* tstruct,
- const string& tstruct_name,
- bool is_result) {
+ t_struct* tstruct,
+ const string& tstruct_name,
+ bool is_result) {
(void)is_result;
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
const string escaped_tstruct_name(escape_string(tstruct->get_name()));
- out << indent() << "func (p *" << tstruct_name << ") CountSetFields" << tstruct_name
- << "() int {"
+ out << indent() << "func (p *" << tstruct_name << ") CountSetFields" << tstruct_name << "() int {"
<< endl;
indent_up();
out << indent() << "count := 0" << endl;
@@ -1336,8 +1333,7 @@
if (!is_pointer_field(*f_iter))
continue;
- const string field_name(
- publicize(escape_string((*f_iter)->get_name())));
+ const string field_name(publicize(escape_string((*f_iter)->get_name())));
out << indent() << "if (p.IsSet" << field_name << "()) {" << endl;
indent_up();
@@ -1351,7 +1347,6 @@
out << indent() << "}" << endl << endl;
}
-
/**
* Generates the read method for a struct
*/
@@ -1374,8 +1369,7 @@
// Required variables does not have IsSet functions, so we need tmp vars to check them.
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
- const string field_name(
- publicize(escape_string((*f_iter)->get_name())));
+ const string field_name(publicize(escape_string((*f_iter)->get_name())));
indent(out) << "var isset" << field_name << " bool = false;" << endl;
}
}
@@ -1430,8 +1424,7 @@
// Mark required field as read
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
- const string field_name(
- publicize(escape_string((*f_iter)->get_name())));
+ const string field_name(publicize(escape_string((*f_iter)->get_name())));
out << indent() << "isset" << field_name << " = true" << endl;
}
@@ -1469,8 +1462,7 @@
// Return error if any required fields are missing.
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
- const string field_name(
- publicize(escape_string((*f_iter)->get_name())));
+ const string field_name(publicize(escape_string((*f_iter)->get_name())));
out << indent() << "if !isset" << field_name << "{" << endl;
out << indent() << " return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, "
"fmt.Errorf(\"Required field " << field_name << " is not set\"));" << endl;
@@ -1517,8 +1509,9 @@
if (tstruct->is_union() && uses_countsetfields) {
std::string tstruct_name(publicize(tstruct->get_name()));
out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 1 {" << endl
- << indent() << " return fmt.Errorf(\"%T write union: exactly one field must be set (%d set).\", p, c)" << endl
- << indent() << "}" << endl;
+ << indent()
+ << " return fmt.Errorf(\"%T write union: exactly one field must be set (%d set).\", p, c)"
+ << endl << indent() << "}" << endl;
}
out << indent() << "if err := oprot.WriteStructBegin(\"" << name << "\"); err != nil {" << endl;
out << indent() << " return thrift.PrependError(fmt.Sprintf("
@@ -1572,8 +1565,7 @@
indent_up();
if (field_required == t_field::T_OPTIONAL) {
- out << indent() << "if p.IsSet" << publicize(field_name) << "() {"
- << endl;
+ out << indent() << "if p.IsSet" << publicize(field_name) << "() {" << endl;
indent_up();
}
@@ -1883,8 +1875,8 @@
f_service_ << indent() << "args := " << argsname << "{" << endl;
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
- f_service_ << indent() << publicize((*fld_iter)->get_name())
- << " : " << variable_name_to_go_name((*fld_iter)->get_name()) << "," << endl;
+ f_service_ << indent() << publicize((*fld_iter)->get_name()) << " : "
+ << variable_name_to_go_name((*fld_iter)->get_name()) << "," << endl;
}
f_service_ << indent() << "}" << endl;
@@ -2030,7 +2022,7 @@
while ((loc = service_module.find(".")) != string::npos) {
service_module.replace(loc, 1, 1, '/');
}
- if(!gen_package_prefix_.empty()) {
+ if (!gen_package_prefix_.empty()) {
service_module = gen_package_prefix_ + service_module;
}
@@ -2631,8 +2623,7 @@
for (xf_iter = x_fields.begin(); xf_iter != x_fields.end(); ++xf_iter) {
f_service_ << indent() << " case " << type_to_go_type(((*xf_iter)->get_type())) << ":"
<< endl;
- f_service_ << indent() << "result."
- << publicize((*xf_iter)->get_name()) << " = v" << endl;
+ f_service_ << indent() << "result." << publicize((*xf_iter)->get_name()) << " = v" << endl;
}
f_service_ << indent() << " default:" << endl;
@@ -2731,11 +2722,10 @@
} else if (type->is_base_type() || type->is_enum()) {
if (declare) {
- t_type* actual_type = use_true_type ? tfield->get_type()->get_true_type()
+ t_type* actual_type = use_true_type ? tfield->get_type()->get_true_type()
: tfield->get_type();
- string type_name = inkey ? type_to_go_key_type(actual_type)
- : type_to_go_type(actual_type);
+ string type_name = inkey ? type_to_go_key_type(actual_type) : type_to_go_type(actual_type);
out << "var " << tfield->get_name() << " " << type_name << endl;
}
diff --git a/compiler/cpp/src/generate/t_gv_generator.cc b/compiler/cpp/src/generate/t_gv_generator.cc
index 59e06a0..b70f2ca 100644
--- a/compiler/cpp/src/generate/t_gv_generator.cc
+++ b/compiler/cpp/src/generate/t_gv_generator.cc
@@ -301,8 +301,7 @@
f_out_ << "function_" << service_name << fn_name;
f_out_ << "[label=\"<return_type>function " << escape_string(fn_name);
f_out_ << " :: ";
- print_type((*fn_iter)->get_returntype(),
- "function_" + service_name + fn_name + ":return_type");
+ print_type((*fn_iter)->get_returntype(), "function_" + service_name + fn_name + ":return_type");
vector<t_field*> args = (*fn_iter)->get_arglist()->get_members();
vector<t_field*>::iterator arg_iter = args.begin();
@@ -314,8 +313,8 @@
print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value());
}
f_out_ << " :: ";
- print_type((*arg_iter)->get_type(), "function_" + service_name + fn_name
- + ":param_" + (*arg_iter)->get_name());
+ print_type((*arg_iter)->get_type(),
+ "function_" + service_name + fn_name + ":param_" + (*arg_iter)->get_name());
}
// end of node
f_out_ << "\"];" << endl;
diff --git a/compiler/cpp/src/generate/t_haxe_generator.cc b/compiler/cpp/src/generate/t_haxe_generator.cc
index 3c4dadf..a0e2f28 100644
--- a/compiler/cpp/src/generate/t_haxe_generator.cc
+++ b/compiler/cpp/src/generate/t_haxe_generator.cc
@@ -200,7 +200,8 @@
t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base();
switch (tbase) {
case t_base_type::TYPE_STRING:
- //case t_base_type::TYPE_I64: - Int64 is not really nullable, even though it behaved that way before Haxe 3.2.0
+ // case t_base_type::TYPE_I64: - Int64 is not really nullable, even though it behaved that
+ // way before Haxe 3.2.0
return true;
default:
return false;
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index c45c798..8c05d4a 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -398,8 +398,7 @@
}
if (use_option_type_) {
- option = string() +
- "import org.apache.thrift.Option;\n";
+ option = string() + "import org.apache.thrift.Option;\n";
}
return string() + hash_builder + "import org.apache.thrift.scheme.IScheme;\n"
@@ -702,7 +701,7 @@
} else if (type->is_enum()) {
std::string namespace_prefix = type->get_program()->get_namespace("java");
if (namespace_prefix.length() > 0) {
- namespace_prefix += ".";
+ namespace_prefix += ".";
}
render << namespace_prefix << value->get_identifier_with_parent();
} else {
@@ -2164,8 +2163,8 @@
out << get_cap_name("size() {") << endl;
indent_up();
- indent(out) << "return (this." << field_name << " == null) ? 0 : " <<
- "this." << field_name << ".size();" << endl;
+ indent(out) << "return (this." << field_name << " == null) ? 0 : "
+ << "this." << field_name << ".size();" << endl;
indent_down();
indent(out) << "}" << endl << endl;
}
@@ -2181,8 +2180,8 @@
// Iterator getter for sets and lists
if (optional) {
- indent(out) << "public Option<java.util.Iterator<" <<
- type_name(element_type, true, false) << ">> get" << cap_name;
+ indent(out) << "public Option<java.util.Iterator<" << type_name(element_type, true, false)
+ << ">> get" << cap_name;
out << get_cap_name("iterator() {") << endl;
indent_up();
@@ -2198,13 +2197,13 @@
indent_down();
indent(out) << "}" << endl << endl;
} else {
- indent(out) << "public java.util.Iterator<" <<
- type_name(element_type, true, false) << "> get" << cap_name;
+ indent(out) << "public java.util.Iterator<" << type_name(element_type, true, false)
+ << "> get" << cap_name;
out << get_cap_name("iterator() {") << endl;
indent_up();
- indent(out) << "return (this." << field_name << " == null) ? null : " <<
- "this." << field_name << ".iterator();" << endl;
+ indent(out) << "return (this." << field_name << " == null) ? null : "
+ << "this." << field_name << ".iterator();" << endl;
indent_down();
indent(out) << "}" << endl << endl;
}
@@ -2264,8 +2263,7 @@
} else {
if (optional) {
indent(out) << "public Option<" << type_name(type, true) << ">";
- if (type->is_base_type() &&
- ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
+ if (type->is_base_type() && ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
out << " is";
} else {
out << " get";
@@ -2286,8 +2284,7 @@
indent(out) << "}" << endl << endl;
} else {
indent(out) << "public " << type_name(type);
- if (type->is_base_type() &&
- ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
+ if (type->is_base_type() && ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
out << " is";
} else {
out << " get";
@@ -2426,17 +2423,20 @@
indent_up();
}
- if (get_true_type(field->get_type())->is_base_type() && ((t_base_type*)(get_true_type(field->get_type())))->is_binary()) {
+ if (get_true_type(field->get_type())->is_base_type()
+ && ((t_base_type*)(get_true_type(field->get_type())))->is_binary()) {
indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << field->get_name() << ", sb);"
<< endl;
- } else if ((field->get_type()->is_set()) &&
- (get_true_type(((t_set*) field->get_type())->get_elem_type())->is_base_type()) &&
- (((t_base_type*) get_true_type(((t_set*) field->get_type())->get_elem_type()))->is_binary())) {
+ } else if ((field->get_type()->is_set())
+ && (get_true_type(((t_set*)field->get_type())->get_elem_type())->is_base_type())
+ && (((t_base_type*)get_true_type(((t_set*)field->get_type())->get_elem_type()))
+ ->is_binary())) {
indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << field->get_name() << ", sb);"
<< endl;
- } else if ((field->get_type()->is_list()) &&
- (get_true_type(((t_list*) field->get_type())->get_elem_type())->is_base_type()) &&
- (((t_base_type*) get_true_type(((t_list*) field->get_type())->get_elem_type()))->is_binary())) {
+ } else if ((field->get_type()->is_list())
+ && (get_true_type(((t_list*)field->get_type())->get_elem_type())->is_base_type())
+ && (((t_base_type*)get_true_type(((t_list*)field->get_type())->get_elem_type()))
+ ->is_binary())) {
indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << field->get_name() << ", sb);"
<< endl;
} else {
@@ -3681,14 +3681,13 @@
indent(out) << prefix << ".put(" << key << ", " << val << ");" << endl;
- if ( reuse_objects_ && !get_true_type(fkey.get_type())->is_base_type()) {
+ if (reuse_objects_ && !get_true_type(fkey.get_type())->is_base_type()) {
indent(out) << key << " = null;" << endl;
}
- if ( reuse_objects_ && !get_true_type(fval.get_type())->is_base_type()) {
+ if (reuse_objects_ && !get_true_type(fval.get_type())->is_base_type()) {
indent(out) << val << " = null;" << endl;
}
-
}
/**
@@ -3715,10 +3714,9 @@
indent(out) << prefix << ".add(" << elem << ");" << endl;
- if ( reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) {
+ if (reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) {
indent(out) << elem << " = null;" << endl;
}
-
}
/**
@@ -3745,10 +3743,9 @@
indent(out) << prefix << ".add(" << elem << ");" << endl;
- if ( reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) {
+ if (reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) {
indent(out) << elem << " = null;" << endl;
}
-
}
/**
@@ -4723,7 +4720,7 @@
if (reuse_objects_ && (t->is_container() || t->is_struct())) {
indent(out) << "if (this." << field->get_name() << " != null) {" << endl;
indent_up();
- indent(out) << "this." << field->get_name() << ".clear();" << endl;
+ indent(out) << "this." << field->get_name() << ".clear();" << endl;
indent_down();
indent(out) << "}" << endl;
@@ -5096,10 +5093,8 @@
time_t seconds = time(NULL);
struct tm* now = localtime(&seconds);
indent(out) << "@Generated(value = \"" << autogen_summary() << "\", date = \""
- << (now->tm_year + 1900)
- << "-" << setfill('0') << setw(2) << (now->tm_mon + 1)
- << "-" << setfill('0') << setw(2) << now->tm_mday << "\")"
- << endl;
+ << (now->tm_year + 1900) << "-" << setfill('0') << setw(2) << (now->tm_mon + 1) << "-"
+ << setfill('0') << setw(2) << now->tm_mday << "\")" << endl;
}
THRIFT_REGISTER_GENERATOR(
diff --git a/compiler/cpp/src/generate/t_lua_generator.cc b/compiler/cpp/src/generate/t_lua_generator.cc
index 1b3dac6..3ca8ae0 100644
--- a/compiler/cpp/src/generate/t_lua_generator.cc
+++ b/compiler/cpp/src/generate/t_lua_generator.cc
@@ -93,11 +93,20 @@
/**
* Deserialization (Read)
*/
- void generate_deserialize_field(std::ofstream& out, t_field* tfield, bool local, std::string prefix = "");
+ void generate_deserialize_field(std::ofstream& out,
+ t_field* tfield,
+ bool local,
+ std::string prefix = "");
- void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, bool local, std::string prefix = "");
+ void generate_deserialize_struct(std::ofstream& out,
+ t_struct* tstruct,
+ bool local,
+ std::string prefix = "");
- void generate_deserialize_container(std::ofstream& out, t_type* ttype, bool local, std::string prefix = "");
+ void generate_deserialize_container(std::ofstream& out,
+ t_type* ttype,
+ bool local,
+ std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
@@ -747,7 +756,10 @@
/**
* Deserialize (Read)
*/
-void t_lua_generator::generate_deserialize_field(ofstream& out, t_field* tfield, bool local, string prefix) {
+void t_lua_generator::generate_deserialize_field(ofstream& out,
+ t_field* tfield,
+ bool local,
+ string prefix) {
t_type* type = get_true_type(tfield->get_type());
if (type->is_void()) {
@@ -805,12 +817,18 @@
}
}
-void t_lua_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, bool local, string prefix) {
- indent(out) << (local ? "local " : "") << prefix << " = " << tstruct->get_name() << ":new{}" << endl << indent() << prefix
- << ":read(iprot)" << endl;
+void t_lua_generator::generate_deserialize_struct(ofstream& out,
+ t_struct* tstruct,
+ bool local,
+ string prefix) {
+ indent(out) << (local ? "local " : "") << prefix << " = " << tstruct->get_name() << ":new{}"
+ << endl << indent() << prefix << ":read(iprot)" << endl;
}
-void t_lua_generator::generate_deserialize_container(ofstream& out, t_type* ttype, bool local, string prefix) {
+void t_lua_generator::generate_deserialize_container(ofstream& out,
+ t_type* ttype,
+ bool local,
+ string prefix) {
string size = tmp("_size");
string ktype = tmp("_ktype");
string vtype = tmp("_vtype");
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index 9dac54a..b25c248 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -754,11 +754,12 @@
if (tservice->get_extends() != NULL) {
if (namespaced_) {
- f_service_ << "require '" << rb_namespace_to_path_prefix(tservice->get_extends()->get_program()->get_namespace("rb")) << underscore(tservice->get_extends()->get_name())
- << "'" << endl;
+ f_service_ << "require '" << rb_namespace_to_path_prefix(
+ tservice->get_extends()->get_program()->get_namespace("rb"))
+ << underscore(tservice->get_extends()->get_name()) << "'" << endl;
} else {
- f_service_ << "require '" << require_prefix_ << underscore(tservice->get_extends()->get_name())
- << "'" << endl;
+ f_service_ << "require '" << require_prefix_
+ << underscore(tservice->get_extends()->get_name()) << "'" << endl;
}
}
diff --git a/compiler/cpp/src/parse/t_enum.h b/compiler/cpp/src/parse/t_enum.h
index 12b4ad8..7b6a020 100644
--- a/compiler/cpp/src/parse/t_enum.h
+++ b/compiler/cpp/src/parse/t_enum.h
@@ -31,7 +31,7 @@
public:
t_enum(t_program* program) : t_type(program) {}
- void set_name(const std::string &name) { name_ = name; }
+ void set_name(const std::string& name) { name_ = name; }
void append(t_enum_value* constant) { constants_.push_back(constant); }
diff --git a/lib/cpp/src/thrift/TOutput.h b/lib/cpp/src/thrift/TOutput.h
index 9053b80..1375f73 100644
--- a/lib/cpp/src/thrift/TOutput.h
+++ b/lib/cpp/src/thrift/TOutput.h
@@ -52,7 +52,6 @@
};
extern TOutput GlobalOutput;
-
}
} // namespace apache::thrift
diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
index 5e1d42b..8d84e4b 100644
--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
@@ -509,10 +509,8 @@
return result;
}
-namespace
-{
-std::string doubleToString(double d)
-{
+namespace {
+std::string doubleToString(double d) {
std::ostringstream str;
str.imbue(std::locale::classic());
str.precision(std::numeric_limits<double>::digits10 + 1);
@@ -817,10 +815,8 @@
return result;
}
-namespace
-{
-double stringToDouble(const std::string& s)
-{
+namespace {
+double stringToDouble(const std::string& s) {
double d;
std::istringstream str(s);
str.imbue(std::locale::classic());
diff --git a/lib/cpp/src/thrift/server/TConnectedClient.cpp b/lib/cpp/src/thrift/server/TConnectedClient.cpp
index 86a81e2..c248e63 100644
--- a/lib/cpp/src/thrift/server/TConnectedClient.cpp
+++ b/lib/cpp/src/thrift/server/TConnectedClient.cpp
@@ -36,22 +36,24 @@
const shared_ptr<TProtocol>& outputProtocol,
const shared_ptr<TServerEventHandler>& eventHandler,
const shared_ptr<TTransport>& client)
-
+
: processor_(processor),
inputProtocol_(inputProtocol),
outputProtocol_(outputProtocol),
eventHandler_(eventHandler),
client_(client),
- opaqueContext_(0) {}
+ opaqueContext_(0) {
+}
-TConnectedClient::~TConnectedClient() {}
+TConnectedClient::~TConnectedClient() {
+}
void TConnectedClient::run() {
if (eventHandler_) {
opaqueContext_ = eventHandler_->createContext(inputProtocol_, outputProtocol_);
}
- for (bool done = false; !done; ) {
+ for (bool done = false; !done;) {
if (eventHandler_) {
eventHandler_->processContext(opaqueContext_, client_);
}
@@ -61,27 +63,25 @@
break;
}
} catch (const TTransportException& ttx) {
- switch (ttx.getType())
- {
- case TTransportException::TIMED_OUT:
- // Receive timeout - continue processing.
- continue;
+ switch (ttx.getType()) {
+ case TTransportException::TIMED_OUT:
+ // Receive timeout - continue processing.
+ continue;
- case TTransportException::END_OF_FILE:
- case TTransportException::INTERRUPTED:
- // Client disconnected or was interrupted. No logging needed. Done.
- done = true;
- break;
+ case TTransportException::END_OF_FILE:
+ case TTransportException::INTERRUPTED:
+ // Client disconnected or was interrupted. No logging needed. Done.
+ done = true;
+ break;
- default:
- {
- // All other transport exceptions are logged.
- // State of connection is unknown. Done.
- string errStr = string("TConnectedClient died: ") + ttx.what();
- GlobalOutput(errStr.c_str());
- done = true;
- break;
- }
+ default: {
+ // All other transport exceptions are logged.
+ // State of connection is unknown. Done.
+ string errStr = string("TConnectedClient died: ") + ttx.what();
+ GlobalOutput(errStr.c_str());
+ done = true;
+ break;
+ }
}
} catch (const TException& tex) {
string errStr = string("TConnectedClient processing exception: ") + tex.what();
@@ -93,8 +93,7 @@
cleanup();
}
-void TConnectedClient::cleanup()
-{
+void TConnectedClient::cleanup() {
if (eventHandler_) {
eventHandler_->deleteContext(opaqueContext_, inputProtocol_, outputProtocol_);
}
@@ -120,7 +119,6 @@
GlobalOutput(errStr.c_str());
}
}
-
}
}
} // apache::thrift::server
diff --git a/lib/cpp/src/thrift/server/TConnectedClient.h b/lib/cpp/src/thrift/server/TConnectedClient.h
index 8931335..3ea065e 100644
--- a/lib/cpp/src/thrift/server/TConnectedClient.h
+++ b/lib/cpp/src/thrift/server/TConnectedClient.h
@@ -37,74 +37,72 @@
* encapsulated here.
*/
-class TConnectedClient : public apache::thrift::concurrency::Runnable
-{
- public:
- /**
- * Constructor.
- *
- * @param[in] processor the TProcessor
- * @param[in] inputProtocol the input TProtocol
- * @param[in] outputProtocol the output TProtocol
- * @param[in] eventHandler the server event handler
- * @param[in] client the TTransport representing the client
- */
- TConnectedClient(
- const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol,
- const boost::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol,
- const boost::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler,
- const boost::shared_ptr<apache::thrift::transport::TTransport>& client);
+class TConnectedClient : public apache::thrift::concurrency::Runnable {
+public:
+ /**
+ * Constructor.
+ *
+ * @param[in] processor the TProcessor
+ * @param[in] inputProtocol the input TProtocol
+ * @param[in] outputProtocol the output TProtocol
+ * @param[in] eventHandler the server event handler
+ * @param[in] client the TTransport representing the client
+ */
+ TConnectedClient(
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol,
+ const boost::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler,
+ const boost::shared_ptr<apache::thrift::transport::TTransport>& client);
- /**
- * Destructor.
- */
- virtual ~TConnectedClient();
+ /**
+ * Destructor.
+ */
+ virtual ~TConnectedClient();
- /**
- * Drive the client until it is done.
- * The client processing loop is:
- *
- * [optional] call eventHandler->createContext once
- * [optional] call eventHandler->processContext per request
- * call processor->process per request
- * handle expected transport exceptions:
- * END_OF_FILE means the client is gone
- * INTERRUPTED means the client was interrupted
- * by TServerTransport::interruptChildren()
- * handle unexpected transport exceptions by logging
- * handle standard exceptions by logging
- * handle unexpected exceptions by logging
- * cleanup()
- */
- virtual void run() /* override */;
+ /**
+ * Drive the client until it is done.
+ * The client processing loop is:
+ *
+ * [optional] call eventHandler->createContext once
+ * [optional] call eventHandler->processContext per request
+ * call processor->process per request
+ * handle expected transport exceptions:
+ * END_OF_FILE means the client is gone
+ * INTERRUPTED means the client was interrupted
+ * by TServerTransport::interruptChildren()
+ * handle unexpected transport exceptions by logging
+ * handle standard exceptions by logging
+ * handle unexpected exceptions by logging
+ * cleanup()
+ */
+ virtual void run() /* override */;
- protected:
- /**
- * Cleanup after a client. This happens if the client disconnects,
- * or if the server is stopped, or if an exception occurs.
- *
- * The cleanup processing is:
- * [optional] call eventHandler->deleteContext once
- * close the inputProtocol's TTransport
- * close the outputProtocol's TTransport
- * close the client
- */
- virtual void cleanup();
+protected:
+ /**
+ * Cleanup after a client. This happens if the client disconnects,
+ * or if the server is stopped, or if an exception occurs.
+ *
+ * The cleanup processing is:
+ * [optional] call eventHandler->deleteContext once
+ * close the inputProtocol's TTransport
+ * close the outputProtocol's TTransport
+ * close the client
+ */
+ virtual void cleanup();
- private:
- boost::shared_ptr<apache::thrift::TProcessor> processor_;
- boost::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_;
- boost::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_;
- boost::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_;
- boost::shared_ptr<apache::thrift::transport::TTransport> client_;
+private:
+ boost::shared_ptr<apache::thrift::TProcessor> processor_;
+ boost::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_;
+ boost::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_;
+ boost::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_;
+ boost::shared_ptr<apache::thrift::transport::TTransport> client_;
- /**
- * Context acquired from the eventHandler_ if one exists.
- */
- void *opaqueContext_;
+ /**
+ * Context acquired from the eventHandler_ if one exists.
+ */
+ void* opaqueContext_;
};
-
}
}
}
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index 631c2d5..d1e9ede 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -1249,7 +1249,7 @@
*/
void TNonblockingServer::serve() {
- if(ioThreads_.empty())
+ if (ioThreads_.empty())
registerEvents(NULL);
// Run the primary (listener) IO thread loop in our main thread; this will
@@ -1400,7 +1400,7 @@
fd_set wfds, efds;
int ret = -1;
int kSize = sizeof(conn);
- const char * pos = (const char *)const_cast_sockopt(&conn);
+ const char* pos = (const char*)const_cast_sockopt(&conn);
while (kSize > 0) {
FD_ZERO(&wfds);
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h
index 7922a68..aacb492 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.h
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.h
@@ -305,14 +305,12 @@
}
public:
- TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory,
- int port)
+ TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, int port)
: TServer(processorFactory) {
init(port);
}
- TNonblockingServer(const boost::shared_ptr<TProcessor>& processor,
- int port)
+ TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, int port)
: TServer(processor) {
init(port);
}
diff --git a/lib/cpp/src/thrift/server/TServerFramework.cpp b/lib/cpp/src/thrift/server/TServerFramework.cpp
index 36dab5b..e843921 100644
--- a/lib/cpp/src/thrift/server/TServerFramework.cpp
+++ b/lib/cpp/src/thrift/server/TServerFramework.cpp
@@ -37,57 +37,64 @@
using boost::shared_ptr;
using std::string;
-TServerFramework::TServerFramework(
- const shared_ptr<TProcessorFactory>& processorFactory,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& transportFactory,
- const shared_ptr<TProtocolFactory>& protocolFactory)
+TServerFramework::TServerFramework(const shared_ptr<TProcessorFactory>& processorFactory,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& transportFactory,
+ const shared_ptr<TProtocolFactory>& protocolFactory)
: TServer(processorFactory, serverTransport, transportFactory, protocolFactory),
clients_(0),
hwm_(0),
- limit_(INT64_MAX) {}
+ limit_(INT64_MAX) {
+}
-TServerFramework::TServerFramework(
- const shared_ptr<TProcessor>& processor,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& transportFactory,
- const shared_ptr<TProtocolFactory>& protocolFactory)
+TServerFramework::TServerFramework(const shared_ptr<TProcessor>& processor,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& transportFactory,
+ const shared_ptr<TProtocolFactory>& protocolFactory)
: TServer(processor, serverTransport, transportFactory, protocolFactory),
clients_(0),
hwm_(0),
- limit_(INT64_MAX) {}
+ limit_(INT64_MAX) {
+}
-TServerFramework::TServerFramework(
- const shared_ptr<TProcessorFactory>& processorFactory,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& inputTransportFactory,
- const shared_ptr<TTransportFactory>& outputTransportFactory,
- const shared_ptr<TProtocolFactory>& inputProtocolFactory,
- const shared_ptr<TProtocolFactory>& outputProtocolFactory)
- : TServer(processorFactory, serverTransport,
- inputTransportFactory, outputTransportFactory,
- inputProtocolFactory, outputProtocolFactory),
+TServerFramework::TServerFramework(const shared_ptr<TProcessorFactory>& processorFactory,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& inputTransportFactory,
+ const shared_ptr<TTransportFactory>& outputTransportFactory,
+ const shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const shared_ptr<TProtocolFactory>& outputProtocolFactory)
+ : TServer(processorFactory,
+ serverTransport,
+ inputTransportFactory,
+ outputTransportFactory,
+ inputProtocolFactory,
+ outputProtocolFactory),
clients_(0),
hwm_(0),
- limit_(INT64_MAX) {}
+ limit_(INT64_MAX) {
+}
-TServerFramework::TServerFramework(
- const shared_ptr<TProcessor>& processor,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& inputTransportFactory,
- const shared_ptr<TTransportFactory>& outputTransportFactory,
- const shared_ptr<TProtocolFactory>& inputProtocolFactory,
- const shared_ptr<TProtocolFactory>& outputProtocolFactory)
- : TServer(processor, serverTransport,
- inputTransportFactory, outputTransportFactory,
- inputProtocolFactory, outputProtocolFactory),
+TServerFramework::TServerFramework(const shared_ptr<TProcessor>& processor,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& inputTransportFactory,
+ const shared_ptr<TTransportFactory>& outputTransportFactory,
+ const shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const shared_ptr<TProtocolFactory>& outputProtocolFactory)
+ : TServer(processor,
+ serverTransport,
+ inputTransportFactory,
+ outputTransportFactory,
+ inputProtocolFactory,
+ outputProtocolFactory),
clients_(0),
hwm_(0),
- limit_(INT64_MAX) {}
+ limit_(INT64_MAX) {
+}
-TServerFramework::~TServerFramework() {}
+TServerFramework::~TServerFramework() {
+}
-template<typename T>
+template <typename T>
static void releaseOneDescriptor(const string& name, T& pTransport) {
if (pTransport) {
try {
@@ -130,10 +137,10 @@
// clients allowed, wait for one or more clients to drain before
// accepting another.
{
- Synchronized sync(mon_);
- while (clients_ >= limit_) {
- mon_.wait();
- }
+ Synchronized sync(mon_);
+ while (clients_ >= limit_) {
+ mon_.wait();
+ }
}
client = serverTransport_->accept();
@@ -143,11 +150,13 @@
inputProtocol = inputProtocolFactory_->getProtocol(inputTransport);
outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
- newlyConnectedClient(
- shared_ptr<TConnectedClient>(
- new TConnectedClient(getProcessor(inputProtocol, outputProtocol, client),
- inputProtocol, outputProtocol, eventHandler_, client),
- bind(&TServerFramework::disposeConnectedClient, this, _1)));
+ newlyConnectedClient(shared_ptr<TConnectedClient>(
+ new TConnectedClient(getProcessor(inputProtocol, outputProtocol, client),
+ inputProtocol,
+ outputProtocol,
+ eventHandler_,
+ client),
+ bind(&TServerFramework::disposeConnectedClient, this, _1)));
} catch (TTransportException& ttx) {
releaseOneDescriptor("inputTransport", inputTransport);
@@ -156,8 +165,8 @@
if (ttx.getType() == TTransportException::TIMED_OUT) {
// Accept timeout - continue processing.
continue;
- } else if (ttx.getType() == TTransportException::END_OF_FILE ||
- ttx.getType() == TTransportException::INTERRUPTED) {
+ } else if (ttx.getType() == TTransportException::END_OF_FILE
+ || ttx.getType() == TTransportException::INTERRUPTED) {
// Server was interrupted. This only happens when stopping.
break;
} else {
@@ -213,7 +222,7 @@
hwm_ = std::max(hwm_, clients_);
}
-void TServerFramework::disposeConnectedClient(TConnectedClient *pClient) {
+void TServerFramework::disposeConnectedClient(TConnectedClient* pClient) {
{
// Count a concurrent client removed.
Synchronized sync(mon_);
@@ -224,8 +233,6 @@
onClientDisconnected(pClient);
delete pClient;
}
-
}
}
} // apache::thrift::server
-
diff --git a/lib/cpp/src/thrift/server/TServerFramework.h b/lib/cpp/src/thrift/server/TServerFramework.h
index 3f16dd1..a22688a 100644
--- a/lib/cpp/src/thrift/server/TServerFramework.h
+++ b/lib/cpp/src/thrift/server/TServerFramework.h
@@ -48,32 +48,32 @@
class TServerFramework : public TServer {
public:
TServerFramework(
- const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory);
+ const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory);
TServerFramework(
- const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory);
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory);
TServerFramework(
- const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
+ const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
TServerFramework(
- const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
virtual ~TServerFramework();
@@ -140,7 +140,7 @@
*
* \param[in] pClient the disconnected client
*/
- virtual void onClientDisconnected(TConnectedClient *pClient) = 0;
+ virtual void onClientDisconnected(TConnectedClient* pClient) = 0;
private:
/**
@@ -154,7 +154,7 @@
* Smart pointer client deletion.
* Calls onClientDisconnected and then deletes pClient.
*/
- void disposeConnectedClient(TConnectedClient *pClient);
+ void disposeConnectedClient(TConnectedClient* pClient);
/**
* Monitor for limiting the number of concurrent clients.
@@ -176,7 +176,6 @@
*/
int64_t limit_;
};
-
}
}
} // apache::thrift::server
diff --git a/lib/cpp/src/thrift/server/TSimpleServer.cpp b/lib/cpp/src/thrift/server/TSimpleServer.cpp
index 3b04f35..2f69ff4 100644
--- a/lib/cpp/src/thrift/server/TSimpleServer.cpp
+++ b/lib/cpp/src/thrift/server/TSimpleServer.cpp
@@ -32,53 +32,54 @@
using boost::shared_ptr;
using std::string;
-TSimpleServer::TSimpleServer(
- const shared_ptr<TProcessorFactory>& processorFactory,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& transportFactory,
- const shared_ptr<TProtocolFactory>& protocolFactory)
- : TServerFramework(processorFactory, serverTransport,
- transportFactory, protocolFactory) {
+TSimpleServer::TSimpleServer(const shared_ptr<TProcessorFactory>& processorFactory,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& transportFactory,
+ const shared_ptr<TProtocolFactory>& protocolFactory)
+ : TServerFramework(processorFactory, serverTransport, transportFactory, protocolFactory) {
TServerFramework::setConcurrentClientLimit(1);
}
-TSimpleServer::TSimpleServer(
- const shared_ptr<TProcessor>& processor,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& transportFactory,
- const shared_ptr<TProtocolFactory>& protocolFactory)
- : TServerFramework(processor, serverTransport,
- transportFactory, protocolFactory) {
+TSimpleServer::TSimpleServer(const shared_ptr<TProcessor>& processor,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& transportFactory,
+ const shared_ptr<TProtocolFactory>& protocolFactory)
+ : TServerFramework(processor, serverTransport, transportFactory, protocolFactory) {
TServerFramework::setConcurrentClientLimit(1);
}
-TSimpleServer::TSimpleServer(
- const shared_ptr<TProcessorFactory>& processorFactory,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& inputTransportFactory,
- const shared_ptr<TTransportFactory>& outputTransportFactory,
- const shared_ptr<TProtocolFactory>& inputProtocolFactory,
- const shared_ptr<TProtocolFactory>& outputProtocolFactory)
- : TServerFramework(processorFactory, serverTransport,
- inputTransportFactory, outputTransportFactory,
- inputProtocolFactory, outputProtocolFactory) {
+TSimpleServer::TSimpleServer(const shared_ptr<TProcessorFactory>& processorFactory,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& inputTransportFactory,
+ const shared_ptr<TTransportFactory>& outputTransportFactory,
+ const shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const shared_ptr<TProtocolFactory>& outputProtocolFactory)
+ : TServerFramework(processorFactory,
+ serverTransport,
+ inputTransportFactory,
+ outputTransportFactory,
+ inputProtocolFactory,
+ outputProtocolFactory) {
TServerFramework::setConcurrentClientLimit(1);
}
-TSimpleServer::TSimpleServer(
- const shared_ptr<TProcessor>& processor,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& inputTransportFactory,
- const shared_ptr<TTransportFactory>& outputTransportFactory,
- const shared_ptr<TProtocolFactory>& inputProtocolFactory,
- const shared_ptr<TProtocolFactory>& outputProtocolFactory)
- : TServerFramework(processor, serverTransport,
- inputTransportFactory, outputTransportFactory,
- inputProtocolFactory, outputProtocolFactory) {
+TSimpleServer::TSimpleServer(const shared_ptr<TProcessor>& processor,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& inputTransportFactory,
+ const shared_ptr<TTransportFactory>& outputTransportFactory,
+ const shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const shared_ptr<TProtocolFactory>& outputProtocolFactory)
+ : TServerFramework(processor,
+ serverTransport,
+ inputTransportFactory,
+ outputTransportFactory,
+ inputProtocolFactory,
+ outputProtocolFactory) {
TServerFramework::setConcurrentClientLimit(1);
}
-TSimpleServer::~TSimpleServer() {}
+TSimpleServer::~TSimpleServer() {
+}
/**
* The main body of customized implementation for TSimpleServer is quite simple:
@@ -92,15 +93,15 @@
/**
* TSimpleServer does not track clients so there is nothing to do here.
*/
-void TSimpleServer::onClientDisconnected(TConnectedClient*) {}
+void TSimpleServer::onClientDisconnected(TConnectedClient*) {
+}
/**
* This makes little sense to the simple server because it is not capable
* of having more than one client at a time, so we hide it.
*/
-void TSimpleServer::setConcurrentClientLimit(int64_t) {}
-
-
+void TSimpleServer::setConcurrentClientLimit(int64_t) {
+}
}
}
} // apache::thrift::server
diff --git a/lib/cpp/src/thrift/server/TSimpleServer.h b/lib/cpp/src/thrift/server/TSimpleServer.h
index 30d5046..391fbec 100644
--- a/lib/cpp/src/thrift/server/TSimpleServer.h
+++ b/lib/cpp/src/thrift/server/TSimpleServer.h
@@ -33,40 +33,43 @@
*/
class TSimpleServer : public TServerFramework {
public:
- TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory);
+ TSimpleServer(
+ const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory);
- TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory);
+ TSimpleServer(
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory);
- TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
+ TSimpleServer(
+ const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
- TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
+ TSimpleServer(
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
virtual ~TSimpleServer();
protected:
virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */;
- virtual void onClientDisconnected(TConnectedClient *pClient) /* override */;
+ virtual void onClientDisconnected(TConnectedClient* pClient) /* override */;
private:
- void setConcurrentClientLimit(int64_t newLimit); // hide
+ void setConcurrentClientLimit(int64_t newLimit); // hide
};
-
}
}
} // apache::thrift::server
diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
index 60634ef..efd7c23 100644
--- a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
@@ -33,63 +33,68 @@
using boost::shared_ptr;
using std::string;
-TThreadPoolServer::TThreadPoolServer(
- const shared_ptr<TProcessorFactory>& processorFactory,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& transportFactory,
- const shared_ptr<TProtocolFactory>& protocolFactory,
- const shared_ptr<ThreadManager>& threadManager)
- : TServerFramework(processorFactory, serverTransport,
- transportFactory, protocolFactory),
+TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessorFactory>& processorFactory,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& transportFactory,
+ const shared_ptr<TProtocolFactory>& protocolFactory,
+ const shared_ptr<ThreadManager>& threadManager)
+ : TServerFramework(processorFactory, serverTransport, transportFactory, protocolFactory),
threadManager_(threadManager),
timeout_(0),
- taskExpiration_(0) {}
+ taskExpiration_(0) {
+}
-TThreadPoolServer::TThreadPoolServer(
- const shared_ptr<TProcessor>& processor,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& transportFactory,
- const shared_ptr<TProtocolFactory>& protocolFactory,
- const shared_ptr<ThreadManager>& threadManager)
- : TServerFramework(processor, serverTransport,
- transportFactory, protocolFactory),
+TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessor>& processor,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& transportFactory,
+ const shared_ptr<TProtocolFactory>& protocolFactory,
+ const shared_ptr<ThreadManager>& threadManager)
+ : TServerFramework(processor, serverTransport, transportFactory, protocolFactory),
threadManager_(threadManager),
timeout_(0),
- taskExpiration_(0) {}
+ taskExpiration_(0) {
+}
-TThreadPoolServer::TThreadPoolServer(
- const shared_ptr<TProcessorFactory>& processorFactory,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& inputTransportFactory,
- const shared_ptr<TTransportFactory>& outputTransportFactory,
- const shared_ptr<TProtocolFactory>& inputProtocolFactory,
- const shared_ptr<TProtocolFactory>& outputProtocolFactory,
- const shared_ptr<ThreadManager>& threadManager)
- : TServerFramework(processorFactory, serverTransport,
- inputTransportFactory, outputTransportFactory,
- inputProtocolFactory, outputProtocolFactory),
+TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessorFactory>& processorFactory,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& inputTransportFactory,
+ const shared_ptr<TTransportFactory>& outputTransportFactory,
+ const shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const shared_ptr<TProtocolFactory>& outputProtocolFactory,
+ const shared_ptr<ThreadManager>& threadManager)
+ : TServerFramework(processorFactory,
+ serverTransport,
+ inputTransportFactory,
+ outputTransportFactory,
+ inputProtocolFactory,
+ outputProtocolFactory),
threadManager_(threadManager),
stop_(false),
timeout_(0),
- taskExpiration_(0) {}
+ taskExpiration_(0) {
+}
-TThreadPoolServer::TThreadPoolServer(
- const shared_ptr<TProcessor>& processor,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& inputTransportFactory,
- const shared_ptr<TTransportFactory>& outputTransportFactory,
- const shared_ptr<TProtocolFactory>& inputProtocolFactory,
- const shared_ptr<TProtocolFactory>& outputProtocolFactory,
- const shared_ptr<ThreadManager>& threadManager)
- : TServerFramework(processor, serverTransport,
- inputTransportFactory, outputTransportFactory,
- inputProtocolFactory, outputProtocolFactory),
+TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessor>& processor,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& inputTransportFactory,
+ const shared_ptr<TTransportFactory>& outputTransportFactory,
+ const shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const shared_ptr<TProtocolFactory>& outputProtocolFactory,
+ const shared_ptr<ThreadManager>& threadManager)
+ : TServerFramework(processor,
+ serverTransport,
+ inputTransportFactory,
+ outputTransportFactory,
+ inputProtocolFactory,
+ outputProtocolFactory),
threadManager_(threadManager),
stop_(false),
timeout_(0),
- taskExpiration_(0) {}
+ taskExpiration_(0) {
+}
-TThreadPoolServer::~TThreadPoolServer() {}
+TThreadPoolServer::~TThreadPoolServer() {
+}
void TThreadPoolServer::serve() {
TServerFramework::serve();
@@ -112,7 +117,8 @@
taskExpiration_ = value;
}
-boost::shared_ptr<apache::thrift::concurrency::ThreadManager> TThreadPoolServer::getThreadManager() const {
+boost::shared_ptr<apache::thrift::concurrency::ThreadManager> TThreadPoolServer::getThreadManager()
+ const {
return threadManager_;
}
@@ -120,8 +126,8 @@
threadManager_->add(pClient, timeout_, taskExpiration_);
}
-void TThreadPoolServer::onClientDisconnected(TConnectedClient*) {}
-
+void TThreadPoolServer::onClientDisconnected(TConnectedClient*) {
+}
}
}
} // apache::thrift::server
diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.h b/lib/cpp/src/thrift/server/TThreadPoolServer.h
index 267dbad..189d7e9 100644
--- a/lib/cpp/src/thrift/server/TThreadPoolServer.h
+++ b/lib/cpp/src/thrift/server/TThreadPoolServer.h
@@ -33,40 +33,40 @@
class TThreadPoolServer : public TServerFramework {
public:
TThreadPoolServer(
- const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory,
- const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager =
- apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
+ const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory,
+ const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager
+ = apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
TThreadPoolServer(
- const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory,
- const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager =
- apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory,
+ const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager
+ = apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
TThreadPoolServer(
- const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory,
- const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager =
- apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
+ const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager
+ = apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
TThreadPoolServer(
- const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory,
- const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager =
- apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager
+ = apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
virtual ~TThreadPoolServer();
@@ -86,7 +86,7 @@
protected:
virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */;
- virtual void onClientDisconnected(TConnectedClient *pClient) /* override */;
+ virtual void onClientDisconnected(TConnectedClient* pClient) /* override */;
boost::shared_ptr<apache::thrift::concurrency::ThreadManager> threadManager_;
@@ -96,7 +96,6 @@
volatile int64_t taskExpiration_;
};
-
}
}
} // apache::thrift::server
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.cpp b/lib/cpp/src/thrift/server/TThreadedServer.cpp
index 98b02c5..92f5cf8 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadedServer.cpp
@@ -36,52 +36,58 @@
using boost::shared_ptr;
using std::string;
-TThreadedServer::TThreadedServer(
- const shared_ptr<TProcessorFactory>& processorFactory,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& transportFactory,
- const shared_ptr<TProtocolFactory>& protocolFactory,
- const shared_ptr<ThreadFactory>& threadFactory)
+TThreadedServer::TThreadedServer(const shared_ptr<TProcessorFactory>& processorFactory,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& transportFactory,
+ const shared_ptr<TProtocolFactory>& protocolFactory,
+ const shared_ptr<ThreadFactory>& threadFactory)
: TServerFramework(processorFactory, serverTransport, transportFactory, protocolFactory),
- threadFactory_(threadFactory) {}
+ threadFactory_(threadFactory) {
+}
-
-TThreadedServer::TThreadedServer(
- const shared_ptr<TProcessor>& processor,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& transportFactory,
- const shared_ptr<TProtocolFactory>& protocolFactory,
- const shared_ptr<ThreadFactory>& threadFactory)
+TThreadedServer::TThreadedServer(const shared_ptr<TProcessor>& processor,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& transportFactory,
+ const shared_ptr<TProtocolFactory>& protocolFactory,
+ const shared_ptr<ThreadFactory>& threadFactory)
: TServerFramework(processor, serverTransport, transportFactory, protocolFactory),
- threadFactory_(threadFactory) {}
+ threadFactory_(threadFactory) {
+}
-TThreadedServer::TThreadedServer(
- const shared_ptr<TProcessorFactory>& processorFactory,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& inputTransportFactory,
- const shared_ptr<TTransportFactory>& outputTransportFactory,
- const shared_ptr<TProtocolFactory>& inputProtocolFactory,
- const shared_ptr<TProtocolFactory>& outputProtocolFactory,
- const shared_ptr<ThreadFactory>& threadFactory)
- : TServerFramework(processorFactory, serverTransport,
- inputTransportFactory, outputTransportFactory,
- inputProtocolFactory, outputProtocolFactory),
- threadFactory_(threadFactory) {}
+TThreadedServer::TThreadedServer(const shared_ptr<TProcessorFactory>& processorFactory,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& inputTransportFactory,
+ const shared_ptr<TTransportFactory>& outputTransportFactory,
+ const shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const shared_ptr<TProtocolFactory>& outputProtocolFactory,
+ const shared_ptr<ThreadFactory>& threadFactory)
+ : TServerFramework(processorFactory,
+ serverTransport,
+ inputTransportFactory,
+ outputTransportFactory,
+ inputProtocolFactory,
+ outputProtocolFactory),
+ threadFactory_(threadFactory) {
+}
-TThreadedServer::TThreadedServer(
- const shared_ptr<TProcessor>& processor,
- const shared_ptr<TServerTransport>& serverTransport,
- const shared_ptr<TTransportFactory>& inputTransportFactory,
- const shared_ptr<TTransportFactory>& outputTransportFactory,
- const shared_ptr<TProtocolFactory>& inputProtocolFactory,
- const shared_ptr<TProtocolFactory>& outputProtocolFactory,
- const shared_ptr<ThreadFactory>& threadFactory)
- : TServerFramework(processor, serverTransport,
- inputTransportFactory, outputTransportFactory,
- inputProtocolFactory, outputProtocolFactory),
- threadFactory_(threadFactory) {}
+TThreadedServer::TThreadedServer(const shared_ptr<TProcessor>& processor,
+ const shared_ptr<TServerTransport>& serverTransport,
+ const shared_ptr<TTransportFactory>& inputTransportFactory,
+ const shared_ptr<TTransportFactory>& outputTransportFactory,
+ const shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const shared_ptr<TProtocolFactory>& outputProtocolFactory,
+ const shared_ptr<ThreadFactory>& threadFactory)
+ : TServerFramework(processor,
+ serverTransport,
+ inputTransportFactory,
+ outputTransportFactory,
+ inputProtocolFactory,
+ outputProtocolFactory),
+ threadFactory_(threadFactory) {
+}
-TThreadedServer::~TThreadedServer() {}
+TThreadedServer::~TThreadedServer() {
+}
void TThreadedServer::serve() {
TServerFramework::serve();
@@ -90,7 +96,7 @@
try {
Synchronized s(clientsMonitor_);
while (getConcurrentClientCount() > 0) {
- clientsMonitor_.wait();
+ clientsMonitor_.wait();
}
} catch (TException& tx) {
string errStr = string("TThreadedServer: Exception joining workers: ") + tx.what();
@@ -109,7 +115,6 @@
clientsMonitor_.notify();
}
}
-
}
}
} // apache::thrift::server
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.h b/lib/cpp/src/thrift/server/TThreadedServer.h
index 21b6a28..cdacfd7 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.h
+++ b/lib/cpp/src/thrift/server/TThreadedServer.h
@@ -34,41 +34,45 @@
*/
class TThreadedServer : public TServerFramework {
public:
- TThreadedServer(const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory,
- const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory =
- boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
- new apache::thrift::concurrency::PlatformThreadFactory));
+ TThreadedServer(
+ const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory,
+ const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory
+ = boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
+ new apache::thrift::concurrency::PlatformThreadFactory));
- TThreadedServer(const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory,
- const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory =
- boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
- new apache::thrift::concurrency::PlatformThreadFactory));
+ TThreadedServer(
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory,
+ const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory
+ = boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
+ new apache::thrift::concurrency::PlatformThreadFactory));
- TThreadedServer(const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory,
- const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory =
- boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
- new apache::thrift::concurrency::PlatformThreadFactory));
+ TThreadedServer(
+ const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory
+ = boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
+ new apache::thrift::concurrency::PlatformThreadFactory));
- TThreadedServer(const boost::shared_ptr<apache::thrift::TProcessor>& processor,
- const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
- const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
- const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory,
- const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory =
- boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
- new apache::thrift::concurrency::PlatformThreadFactory));
+ TThreadedServer(
+ const boost::shared_ptr<apache::thrift::TProcessor>& processor,
+ const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory,
+ const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory
+ = boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
+ new apache::thrift::concurrency::PlatformThreadFactory));
virtual ~TThreadedServer();
@@ -80,12 +84,11 @@
protected:
virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */;
- virtual void onClientDisconnected(TConnectedClient *pClient) /* override */;
+ virtual void onClientDisconnected(TConnectedClient* pClient) /* override */;
boost::shared_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory_;
apache::thrift::concurrency::Monitor clientsMonitor_;
};
-
}
}
} // apache::thrift::server
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
index af551c3..700bdd5 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
@@ -203,8 +203,7 @@
// Check for oversized frame
if (sz > static_cast<int32_t>(maxFrameSize_))
- throw TTransportException(TTransportException::CORRUPTED_DATA,
- "Received an oversized frame");
+ throw TTransportException(TTransportException::CORRUPTED_DATA, "Received an oversized frame");
// Read the frame payload, and reset markers.
if (sz > static_cast<int32_t>(rBufSize_)) {
@@ -369,14 +368,14 @@
}
// Allocate into a new pointer so we don't bork ours if it fails.
- uint8_t* new_buffer = static_cast<uint8_t *>(std::realloc(buffer_, new_size));
+ uint8_t* new_buffer = static_cast<uint8_t*>(std::realloc(buffer_, new_size));
if (new_buffer == NULL) {
throw std::bad_alloc();
}
- rBase_ = new_buffer + (rBase_ - buffer_) ;
- rBound_ = new_buffer + (rBound_ - buffer_) ;
- wBase_ = new_buffer + (wBase_ - buffer_) ;
+ rBase_ = new_buffer + (rBase_ - buffer_);
+ rBound_ = new_buffer + (rBound_ - buffer_);
+ wBase_ = new_buffer + (wBase_ - buffer_);
wBound_ = new_buffer + new_size;
buffer_ = new_buffer;
bufferSize_ = new_size;
diff --git a/lib/cpp/src/thrift/transport/TFileTransport.cpp b/lib/cpp/src/thrift/transport/TFileTransport.cpp
index 8f6fe8e..85e88b9 100644
--- a/lib/cpp/src/thrift/transport/TFileTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TFileTransport.cpp
@@ -239,7 +239,7 @@
assert(!forceFlush_);
// add to the buffer
- eventInfo *pEvent = toEnqueue.release();
+ eventInfo* pEvent = toEnqueue.release();
if (!enqueueBuffer_->addEvent(pEvent)) {
delete pEvent;
return;
diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp
index 421af6a..7e1484d 100644
--- a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp
@@ -32,7 +32,8 @@
factory_->server(true);
}
-TSSLServerSocket::TSSLServerSocket(const std::string& address, int port,
+TSSLServerSocket::TSSLServerSocket(const std::string& address,
+ int port,
boost::shared_ptr<TSSLSocketFactory> factory)
: TServerSocket(address, port), factory_(factory) {
factory_->server(true);
diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.h b/lib/cpp/src/thrift/transport/TSSLServerSocket.h
index 7d2dfcc..dfdbde8 100644
--- a/lib/cpp/src/thrift/transport/TSSLServerSocket.h
+++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.h
@@ -49,7 +49,8 @@
* @param port Listening port
* @param factory SSL socket factory implementation
*/
- TSSLServerSocket(const std::string& address, int port,
+ TSSLServerSocket(const std::string& address,
+ int port,
boost::shared_ptr<TSSLSocketFactory> factory);
/**
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp
index f5c3ea5..daa1524 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -70,10 +70,9 @@
return reinterpret_cast<SOCKOPT_CAST_T*>(v);
}
-void destroyer_of_fine_sockets(THRIFT_SOCKET *ssock)
-{
- ::THRIFT_CLOSESOCKET(*ssock);
- delete ssock;
+void destroyer_of_fine_sockets(THRIFT_SOCKET* ssock) {
+ ::THRIFT_CLOSESOCKET(*ssock);
+ delete ssock;
}
namespace apache {
@@ -99,8 +98,8 @@
listening_(false),
interruptSockWriter_(THRIFT_INVALID_SOCKET),
interruptSockReader_(THRIFT_INVALID_SOCKET),
- childInterruptSockWriter_(THRIFT_INVALID_SOCKET)
-{}
+ childInterruptSockWriter_(THRIFT_INVALID_SOCKET) {
+}
TServerSocket::TServerSocket(int port, int sendTimeout, int recvTimeout)
: port_(port),
@@ -118,8 +117,8 @@
listening_(false),
interruptSockWriter_(THRIFT_INVALID_SOCKET),
interruptSockReader_(THRIFT_INVALID_SOCKET),
- childInterruptSockWriter_(THRIFT_INVALID_SOCKET)
-{}
+ childInterruptSockWriter_(THRIFT_INVALID_SOCKET) {
+}
TServerSocket::TServerSocket(const string& address, int port)
: port_(port),
@@ -138,8 +137,8 @@
listening_(false),
interruptSockWriter_(THRIFT_INVALID_SOCKET),
interruptSockReader_(THRIFT_INVALID_SOCKET),
- childInterruptSockWriter_(THRIFT_INVALID_SOCKET)
-{}
+ childInterruptSockWriter_(THRIFT_INVALID_SOCKET) {
+}
TServerSocket::TServerSocket(const string& path)
: port_(0),
@@ -158,8 +157,8 @@
listening_(false),
interruptSockWriter_(THRIFT_INVALID_SOCKET),
interruptSockReader_(THRIFT_INVALID_SOCKET),
- childInterruptSockWriter_(THRIFT_INVALID_SOCKET)
-{}
+ childInterruptSockWriter_(THRIFT_INVALID_SOCKET) {
+}
TServerSocket::~TServerSocket() {
close();
@@ -212,8 +211,7 @@
THRIFT_SOCKET sv[2];
// Create the socket pair used to interrupt
if (-1 == THRIFT_SOCKETPAIR(AF_LOCAL, SOCK_STREAM, 0, sv)) {
- GlobalOutput.perror("TServerSocket::listen() socketpair() interrupt",
- THRIFT_GET_SOCKET_ERROR);
+ GlobalOutput.perror("TServerSocket::listen() socketpair() interrupt", THRIFT_GET_SOCKET_ERROR);
interruptSockWriter_ = THRIFT_INVALID_SOCKET;
interruptSockReader_ = THRIFT_INVALID_SOCKET;
} else {
@@ -224,14 +222,13 @@
// Create the socket pair used to interrupt all clients
if (-1 == THRIFT_SOCKETPAIR(AF_LOCAL, SOCK_STREAM, 0, sv)) {
GlobalOutput.perror("TServerSocket::listen() socketpair() childInterrupt",
- THRIFT_GET_SOCKET_ERROR);
+ THRIFT_GET_SOCKET_ERROR);
childInterruptSockWriter_ = THRIFT_INVALID_SOCKET;
pChildInterruptSockReader_.reset();
} else {
childInterruptSockWriter_ = sv[1];
- pChildInterruptSockReader_ =
- boost::shared_ptr<THRIFT_SOCKET>(new THRIFT_SOCKET(sv[0]),
- destroyer_of_fine_sockets);
+ pChildInterruptSockReader_
+ = boost::shared_ptr<THRIFT_SOCKET>(new THRIFT_SOCKET(sv[0]), destroyer_of_fine_sockets);
}
// Validate port number
@@ -388,7 +385,8 @@
GlobalOutput.perror("TServerSocket::listen() THRIFT_FCNTL() THRIFT_F_GETFL ", errno_copy);
close();
throw TTransportException(TTransportException::NOT_OPEN,
- "THRIFT_FCNTL() THRIFT_F_GETFL failed", errno_copy);
+ "THRIFT_FCNTL() THRIFT_F_GETFL failed",
+ errno_copy);
}
if (-1 == THRIFT_FCNTL(serverSocket_, THRIFT_F_SETFL, flags | THRIFT_O_NONBLOCK)) {
@@ -396,7 +394,8 @@
GlobalOutput.perror("TServerSocket::listen() THRIFT_FCNTL() THRIFT_O_NONBLOCK ", errno_copy);
close();
throw TTransportException(TTransportException::NOT_OPEN,
- "THRIFT_FCNTL() THRIFT_F_SETFL THRIFT_O_NONBLOCK failed", errno_copy);
+ "THRIFT_FCNTL() THRIFT_F_SETFL THRIFT_O_NONBLOCK failed",
+ errno_copy);
}
// prepare the port information
@@ -413,7 +412,8 @@
if (len > sizeof(((sockaddr_un*)NULL)->sun_path)) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
GlobalOutput.perror("TSocket::listen() Unix Domain socket path too long", errno_copy);
- throw TTransportException(TTransportException::NOT_OPEN, "Unix Domain socket path too long",
+ throw TTransportException(TTransportException::NOT_OPEN,
+ "Unix Domain socket path too long",
errno_copy);
}
@@ -649,7 +649,6 @@
pChildInterruptSockReader_.reset();
listening_ = false;
}
-
}
}
} // apache::thrift::transport
diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp
index 4156d7e..2450d50 100644
--- a/lib/cpp/src/thrift/transport/TSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSocket.cpp
@@ -143,21 +143,20 @@
#endif
}
-TSocket::TSocket(THRIFT_SOCKET socket,
- boost::shared_ptr<THRIFT_SOCKET> interruptListener) :
- host_(""),
- port_(0),
- path_(""),
- socket_(socket),
- interruptListener_(interruptListener),
- connTimeout_(0),
- sendTimeout_(0),
- recvTimeout_(0),
- keepAlive_(false),
- lingerOn_(1),
- lingerVal_(0),
- noDelay_(1),
- maxRecvRetries_(5) {
+TSocket::TSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener)
+ : host_(""),
+ port_(0),
+ path_(""),
+ socket_(socket),
+ interruptListener_(interruptListener),
+ connTimeout_(0),
+ sendTimeout_(0),
+ recvTimeout_(0),
+ keepAlive_(false),
+ lingerOn_(1),
+ lingerVal_(0),
+ noDelay_(1),
+ maxRecvRetries_(5) {
cachedPeerAddr_.ipv4.sin_family = AF_UNSPEC;
#ifdef SO_NOSIGPIPE
{
@@ -177,11 +176,10 @@
bool TSocket::peek() {
if (!isOpen()) {
- return false;
+ return false;
}
- if (interruptListener_)
- {
- for (int retries = 0; ; ) {
+ if (interruptListener_) {
+ for (int retries = 0;;) {
struct THRIFT_POLLFD fds[2];
std::memset(fds, 0, sizeof(fds));
fds[0].fd = socket_;
@@ -515,8 +513,7 @@
int got = 0;
- if (interruptListener_)
- {
+ if (interruptListener_) {
struct THRIFT_POLLFD fds[2];
std::memset(fds, 0, sizeof(fds));
fds[0].fd = socket_;
@@ -536,12 +533,10 @@
} else if (ret > 0) {
// Check the interruptListener
if (fds[1].revents & THRIFT_POLLIN) {
- throw TTransportException(TTransportException::INTERRUPTED,
- "Interrupted");
+ throw TTransportException(TTransportException::INTERRUPTED, "Interrupted");
}
} else /* ret == 0 */ {
- throw TTransportException(TTransportException::TIMED_OUT,
- "THRIFT_EAGAIN (timed out)");
+ throw TTransportException(TTransportException::TIMED_OUT, "THRIFT_EAGAIN (timed out)");
}
// falling through means there is something to recv and it cannot block
@@ -562,9 +557,8 @@
// check if this is the lack of resources or timeout case
struct timeval end;
THRIFT_GETTIMEOFDAY(&end, NULL);
- uint32_t readElapsedMicros
- = static_cast<uint32_t>(((end.tv_sec - begin.tv_sec) * 1000 * 1000)
- + (end.tv_usec - begin.tv_usec));
+ uint32_t readElapsedMicros = static_cast<uint32_t>(((end.tv_sec - begin.tv_sec) * 1000 * 1000)
+ + (end.tv_usec - begin.tv_usec));
if (!eagainThresholdMicros || (readElapsedMicros < eagainThresholdMicros)) {
if (retries++ < maxRecvRetries_) {
diff --git a/lib/cpp/src/thrift/transport/TSocket.h b/lib/cpp/src/thrift/transport/TSocket.h
index 09a64e3..9f0074d 100644
--- a/lib/cpp/src/thrift/transport/TSocket.h
+++ b/lib/cpp/src/thrift/transport/TSocket.h
@@ -257,8 +257,7 @@
* Constructor to create socket from file descriptor that
* can be interrupted safely.
*/
- TSocket(THRIFT_SOCKET socket,
- boost::shared_ptr<THRIFT_SOCKET> interruptListener);
+ TSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener);
/**
* Set a cache of the peer address (used when trivially available: e.g.
diff --git a/lib/cpp/test/TFDTransportTest.cpp b/lib/cpp/test/TFDTransportTest.cpp
index 47780ff..edbc55a 100644
--- a/lib/cpp/test/TFDTransportTest.cpp
+++ b/lib/cpp/test/TFDTransportTest.cpp
@@ -30,8 +30,8 @@
int main() {
{ TFDTransport t(256, TFDTransport::NO_CLOSE_ON_DESTROY); }
- // Disabled on MSVC because the RTL asserts on an invalid file descriptor
- // in both debug and release mode; at least in MSVCR100 (Visual Studio 2010)
+// Disabled on MSVC because the RTL asserts on an invalid file descriptor
+// in both debug and release mode; at least in MSVCR100 (Visual Studio 2010)
#if !defined(WIN32)
try {
{
diff --git a/lib/cpp/test/TMemoryBufferTest.cpp b/lib/cpp/test/TMemoryBufferTest.cpp
index ec0f392..b562b34 100644
--- a/lib/cpp/test/TMemoryBufferTest.cpp
+++ b/lib/cpp/test/TMemoryBufferTest.cpp
@@ -36,8 +36,7 @@
using std::endl;
using std::string;
-BOOST_AUTO_TEST_CASE(test_read_write_grow)
-{
+BOOST_AUTO_TEST_CASE(test_read_write_grow) {
// Added to test the fix for THRIFT-1248
TMemoryBuffer uut;
const int maxSize = 65536;
@@ -45,25 +44,21 @@
std::vector<uint8_t> buf;
buf.resize(maxSize);
- for (uint32_t i = 0; i < maxSize; ++i)
- {
+ for (uint32_t i = 0; i < maxSize; ++i) {
buf[i] = static_cast<uint8_t>(i);
}
- for (uint32_t i = 1; i < maxSize; i *= 2)
- {
+ for (uint32_t i = 1; i < maxSize; i *= 2) {
uut.write(&buf[0], i);
}
- for (uint32_t i = 1; i < maxSize; i *= 2)
- {
+ for (uint32_t i = 1; i < maxSize; i *= 2) {
uut.read(verify, i);
BOOST_CHECK_EQUAL(0, ::memcmp(verify, &buf[0], i));
}
}
-BOOST_AUTO_TEST_CASE(test_roundtrip)
-{
+BOOST_AUTO_TEST_CASE(test_roundtrip) {
shared_ptr<TMemoryBuffer> strBuffer(new TMemoryBuffer());
shared_ptr<TBinaryProtocol> binaryProtcol(new TBinaryProtocol(strBuffer));
@@ -85,8 +80,7 @@
assert(a == a2);
}
-BOOST_AUTO_TEST_CASE(test_copy)
-{
+BOOST_AUTO_TEST_CASE(test_copy) {
string* str1 = new string("abcd1234");
const char* data1 = str1->data();
TMemoryBuffer buf((uint8_t*)str1->data(),
@@ -108,8 +102,7 @@
assert(str4 == "67891234");
}
-BOOST_AUTO_TEST_CASE(test_exceptions)
-{
+BOOST_AUTO_TEST_CASE(test_exceptions) {
char data[] = "foo\0bar";
TMemoryBuffer buf1((uint8_t*)data, 7, TMemoryBuffer::OBSERVE);
diff --git a/lib/cpp/test/TServerIntegrationTest.cpp b/lib/cpp/test/TServerIntegrationTest.cpp
index fec1b9c..42ec5d6 100644
--- a/lib/cpp/test/TServerIntegrationTest.cpp
+++ b/lib/cpp/test/TServerIntegrationTest.cpp
@@ -68,8 +68,7 @@
/**
* preServe runs after listen() is successful, when we can connect
*/
-class TServerReadyEventHandler : public TServerEventHandler, public Monitor
-{
+class TServerReadyEventHandler : public TServerEventHandler, public Monitor {
public:
TServerReadyEventHandler() : isListening_(false), accepted_(0) {}
virtual ~TServerReadyEventHandler() {}
@@ -90,6 +89,7 @@
}
bool isListening() const { return isListening_; }
uint64_t acceptedCount() const { return accepted_; }
+
private:
bool isListening_;
uint64_t accepted_;
@@ -127,16 +127,11 @@
THRIFT_UNUSED_VARIABLE(length);
}
- void onewayWait() {
- }
+ void onewayWait() {}
- void exceptionWait(const std::string& message) {
- THRIFT_UNUSED_VARIABLE(message);
- }
+ void exceptionWait(const std::string& message) { THRIFT_UNUSED_VARIABLE(message); }
- void unexpectedExceptionWait(const std::string& message) {
- THRIFT_UNUSED_VARIABLE(message);
- }
+ void unexpectedExceptionWait(const std::string& message) { THRIFT_UNUSED_VARIABLE(message); }
protected:
Mutex mutex_;
@@ -144,34 +139,31 @@
std::vector<std::string> strings_;
};
-void autoSocketCloser(TSocket *pSock) {
+void autoSocketCloser(TSocket* pSock) {
pSock->close();
delete pSock;
}
-template<class TServerType>
-class TServerIntegrationTestFixture : public TestPortFixture
-{
+template <class TServerType>
+class TServerIntegrationTestFixture : public TestPortFixture {
public:
- TServerIntegrationTestFixture(const boost::shared_ptr<TProcessorFactory>& _processorFactory) :
- pServer(new TServerType(
- _processorFactory,
- boost::shared_ptr<TServerTransport>(new TServerSocket("localhost", m_serverPort)),
- boost::shared_ptr<TTransportFactory>(new TTransportFactory),
- boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))),
- pEventHandler(boost::shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler))
- {
+ TServerIntegrationTestFixture(const boost::shared_ptr<TProcessorFactory>& _processorFactory)
+ : pServer(new TServerType(_processorFactory,
+ boost::shared_ptr<TServerTransport>(
+ new TServerSocket("localhost", m_serverPort)),
+ boost::shared_ptr<TTransportFactory>(new TTransportFactory),
+ boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))),
+ pEventHandler(boost::shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler)) {
pServer->setServerEventHandler(pEventHandler);
}
- TServerIntegrationTestFixture(const boost::shared_ptr<TProcessor>& _processor) :
- pServer(new TServerType(
- _processor,
- boost::shared_ptr<TServerTransport>(new TServerSocket("localhost", 0)),
- boost::shared_ptr<TTransportFactory>(new TTransportFactory),
- boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))),
- pEventHandler(boost::shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler))
- {
+ TServerIntegrationTestFixture(const boost::shared_ptr<TProcessor>& _processor)
+ : pServer(
+ new TServerType(_processor,
+ boost::shared_ptr<TServerTransport>(new TServerSocket("localhost", 0)),
+ boost::shared_ptr<TTransportFactory>(new TTransportFactory),
+ boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))),
+ pEventHandler(boost::shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler)) {
pServer->setServerEventHandler(pEventHandler);
}
@@ -181,7 +173,7 @@
// block until listen() completes so clients will be able to connect
Synchronized sync(*(pEventHandler.get()));
while (!pEventHandler->isListening()) {
- pEventHandler->wait();
+ pEventHandler->wait();
}
BOOST_MESSAGE("server is listening");
@@ -190,7 +182,7 @@
void blockUntilAccepted(uint64_t numAccepted) {
Synchronized sync(*(pEventHandler.get()));
while (pEventHandler->acceptedCount() < numAccepted) {
- pEventHandler->wait();
+ pEventHandler->wait();
}
BOOST_MESSAGE(boost::format("server has accepted %1%") % numAccepted);
@@ -207,12 +199,10 @@
}
}
- ~TServerIntegrationTestFixture() {
- stopServer();
- }
+ ~TServerIntegrationTestFixture() { stopServer(); }
int getServerPort() {
- TServerSocket *pSock = dynamic_cast<TServerSocket *>(pServer->getServerTransport().get());
+ TServerSocket* pSock = dynamic_cast<TServerSocket*>(pServer->getServerTransport().get());
return pSock->getPort();
}
@@ -227,24 +217,23 @@
std::vector<boost::shared_ptr<boost::thread> > holdThreads;
for (int64_t i = 0; i < numToMake; ++i) {
- boost::shared_ptr<TSocket> pClientSock(new TSocket("localhost", getServerPort()), autoSocketCloser);
- holdSockets.push_back(pClientSock);
- boost::shared_ptr<TProtocol> pClientProtocol(new TBinaryProtocol(pClientSock));
- ParentServiceClient client(pClientProtocol);
- pClientSock->open();
- client.incrementGeneration();
- holdThreads.push_back(
- boost::shared_ptr<boost::thread>(
- new boost::thread(
- boost::bind(&TServerIntegrationTestFixture::delayClose, this,
- pClientSock, milliseconds(100 * numToMake)))));
+ boost::shared_ptr<TSocket> pClientSock(new TSocket("localhost", getServerPort()),
+ autoSocketCloser);
+ holdSockets.push_back(pClientSock);
+ boost::shared_ptr<TProtocol> pClientProtocol(new TBinaryProtocol(pClientSock));
+ ParentServiceClient client(pClientProtocol);
+ pClientSock->open();
+ client.incrementGeneration();
+ holdThreads.push_back(boost::shared_ptr<boost::thread>(
+ new boost::thread(boost::bind(&TServerIntegrationTestFixture::delayClose,
+ this,
+ pClientSock,
+ milliseconds(100 * numToMake)))));
}
BOOST_CHECK_EQUAL(expectedHWM, pServer->getConcurrentClientCountHWM());
stopServer();
- BOOST_FOREACH(boost::shared_ptr<boost::thread> pThread, holdThreads) {
- pThread->join();
- }
+ BOOST_FOREACH (boost::shared_ptr<boost::thread> pThread, holdThreads) { pThread->join(); }
holdThreads.clear();
holdSockets.clear();
}
@@ -254,183 +243,191 @@
boost::shared_ptr<boost::thread> pServerThread;
};
-template<class TServerType>
-class TServerIntegrationProcessorFactoryTestFixture : public TServerIntegrationTestFixture<TServerType>
-{
+template <class TServerType>
+class TServerIntegrationProcessorFactoryTestFixture
+ : public TServerIntegrationTestFixture<TServerType> {
public:
- TServerIntegrationProcessorFactoryTestFixture() :
- TServerIntegrationTestFixture<TServerType>(
- boost::make_shared<ParentServiceProcessorFactory>(
- boost::make_shared<ParentServiceIfSingletonFactory>(
- boost::make_shared<ParentHandler>()))) { }
+ TServerIntegrationProcessorFactoryTestFixture()
+ : TServerIntegrationTestFixture<TServerType>(boost::make_shared<ParentServiceProcessorFactory>(
+ boost::make_shared<ParentServiceIfSingletonFactory>(
+ boost::make_shared<ParentHandler>()))) {}
};
-template<class TServerType>
-class TServerIntegrationProcessorTestFixture : public TServerIntegrationTestFixture<TServerType>
-{
+template <class TServerType>
+class TServerIntegrationProcessorTestFixture : public TServerIntegrationTestFixture<TServerType> {
public:
- TServerIntegrationProcessorTestFixture() :
- TServerIntegrationTestFixture<TServerType>(
- boost::make_shared<ParentServiceProcessor>(
- boost::make_shared<ParentHandler>())) { }
+ TServerIntegrationProcessorTestFixture()
+ : TServerIntegrationTestFixture<TServerType>(
+ boost::make_shared<ParentServiceProcessor>(boost::make_shared<ParentHandler>())) {}
};
BOOST_AUTO_TEST_SUITE(constructors)
-BOOST_FIXTURE_TEST_CASE(test_simple_factory, TServerIntegrationProcessorFactoryTestFixture<TSimpleServer>)
-{
- baseline(3, 1);
+BOOST_FIXTURE_TEST_CASE(test_simple_factory,
+ TServerIntegrationProcessorFactoryTestFixture<TSimpleServer>) {
+ baseline(3, 1);
}
-BOOST_FIXTURE_TEST_CASE(test_simple, TServerIntegrationProcessorTestFixture<TSimpleServer>)
-{
- baseline(3, 1);
+BOOST_FIXTURE_TEST_CASE(test_simple, TServerIntegrationProcessorTestFixture<TSimpleServer>) {
+ baseline(3, 1);
}
-BOOST_FIXTURE_TEST_CASE(test_threaded_factory, TServerIntegrationProcessorFactoryTestFixture<TThreadedServer>)
-{
- baseline(10, 10);
+BOOST_FIXTURE_TEST_CASE(test_threaded_factory,
+ TServerIntegrationProcessorFactoryTestFixture<TThreadedServer>) {
+ baseline(10, 10);
}
-BOOST_FIXTURE_TEST_CASE(test_threaded, TServerIntegrationProcessorTestFixture<TThreadedServer>)
-{
- baseline(10, 10);
+BOOST_FIXTURE_TEST_CASE(test_threaded, TServerIntegrationProcessorTestFixture<TThreadedServer>) {
+ baseline(10, 10);
}
-BOOST_FIXTURE_TEST_CASE(test_threaded_bound, TServerIntegrationProcessorTestFixture<TThreadedServer>)
-{
- pServer->setConcurrentClientLimit(4);
- baseline(10, 4);
+BOOST_FIXTURE_TEST_CASE(test_threaded_bound,
+ TServerIntegrationProcessorTestFixture<TThreadedServer>) {
+ pServer->setConcurrentClientLimit(4);
+ baseline(10, 4);
}
-BOOST_FIXTURE_TEST_CASE(test_threadpool_factory, TServerIntegrationProcessorFactoryTestFixture<TThreadPoolServer>)
-{
- pServer->getThreadManager()->threadFactory(
- boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
- new apache::thrift::concurrency::PlatformThreadFactory));
- pServer->getThreadManager()->start();
+BOOST_FIXTURE_TEST_CASE(test_threadpool_factory,
+ TServerIntegrationProcessorFactoryTestFixture<TThreadPoolServer>) {
+ pServer->getThreadManager()->threadFactory(
+ boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
+ new apache::thrift::concurrency::PlatformThreadFactory));
+ pServer->getThreadManager()->start();
- // thread factory has 4 threads as a default
- // thread factory however is a bad way to limit concurrent clients
- // as accept() will be called to grab a 5th client socket, in this case
- // and then the thread factory will block adding the thread to manage
- // that client.
- baseline(10, 5);
+ // thread factory has 4 threads as a default
+ // thread factory however is a bad way to limit concurrent clients
+ // as accept() will be called to grab a 5th client socket, in this case
+ // and then the thread factory will block adding the thread to manage
+ // that client.
+ baseline(10, 5);
}
-BOOST_FIXTURE_TEST_CASE(test_threadpool, TServerIntegrationProcessorTestFixture<TThreadPoolServer>)
-{
- pServer->getThreadManager()->threadFactory(
- boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
- new apache::thrift::concurrency::PlatformThreadFactory));
- pServer->getThreadManager()->start();
+BOOST_FIXTURE_TEST_CASE(test_threadpool,
+ TServerIntegrationProcessorTestFixture<TThreadPoolServer>) {
+ pServer->getThreadManager()->threadFactory(
+ boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
+ new apache::thrift::concurrency::PlatformThreadFactory));
+ pServer->getThreadManager()->start();
- // thread factory has 4 threads as a default
- // thread factory however is a bad way to limit concurrent clients
- // as accept() will be called to grab a 5th client socket, in this case
- // and then the thread factory will block adding the thread to manage
- // that client.
- baseline(10, 5);
+ // thread factory has 4 threads as a default
+ // thread factory however is a bad way to limit concurrent clients
+ // as accept() will be called to grab a 5th client socket, in this case
+ // and then the thread factory will block adding the thread to manage
+ // that client.
+ baseline(10, 5);
}
-BOOST_FIXTURE_TEST_CASE(test_threadpool_bound, TServerIntegrationProcessorTestFixture<TThreadPoolServer>)
-{
- pServer->getThreadManager()->threadFactory(
- boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
- new apache::thrift::concurrency::PlatformThreadFactory));
- pServer->getThreadManager()->start();
- pServer->setConcurrentClientLimit(4);
+BOOST_FIXTURE_TEST_CASE(test_threadpool_bound,
+ TServerIntegrationProcessorTestFixture<TThreadPoolServer>) {
+ pServer->getThreadManager()->threadFactory(
+ boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
+ new apache::thrift::concurrency::PlatformThreadFactory));
+ pServer->getThreadManager()->start();
+ pServer->setConcurrentClientLimit(4);
- baseline(10, 4);
+ baseline(10, 4);
}
BOOST_AUTO_TEST_SUITE_END()
+BOOST_FIXTURE_TEST_SUITE(TServerIntegrationTest,
+ TServerIntegrationProcessorTestFixture<TThreadedServer>)
-BOOST_FIXTURE_TEST_SUITE ( TServerIntegrationTest, TServerIntegrationProcessorTestFixture<TThreadedServer> )
+BOOST_AUTO_TEST_CASE(test_stop_with_interruptable_clients_connected) {
+ // This tests THRIFT-2441 new behavior: stopping the server disconnects clients
-BOOST_AUTO_TEST_CASE(test_stop_with_interruptable_clients_connected)
-{
- // This tests THRIFT-2441 new behavior: stopping the server disconnects clients
+ startServer();
- startServer();
+ boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()),
+ autoSocketCloser);
+ pClientSock1->open();
- boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser);
- pClientSock1->open();
+ boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()),
+ autoSocketCloser);
+ pClientSock2->open();
- boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser);
- pClientSock2->open();
+ // Ensure they have been accepted
+ blockUntilAccepted(2);
- // Ensure they have been accepted
- blockUntilAccepted(2);
+ // The test fixture destructor will force the sockets to disconnect
+ // Prior to THRIFT-2441, pServer->stop() would hang until clients disconnected
+ stopServer();
- // The test fixture destructor will force the sockets to disconnect
- // Prior to THRIFT-2441, pServer->stop() would hang until clients disconnected
- stopServer();
-
- // extra proof the server end disconnected the clients
- uint8_t buf[1];
- BOOST_CHECK_EQUAL(0, pClientSock1->read(&buf[0], 1)); // 0 = disconnected
- BOOST_CHECK_EQUAL(0, pClientSock2->read(&buf[0], 1)); // 0 = disconnected
+ // extra proof the server end disconnected the clients
+ uint8_t buf[1];
+ BOOST_CHECK_EQUAL(0, pClientSock1->read(&buf[0], 1)); // 0 = disconnected
+ BOOST_CHECK_EQUAL(0, pClientSock2->read(&buf[0], 1)); // 0 = disconnected
}
-BOOST_AUTO_TEST_CASE(test_stop_with_uninterruptable_clients_connected)
-{
- // This tests pre-THRIFT-2441 behavior: stopping the server blocks until clients
- // disconnect.
+BOOST_AUTO_TEST_CASE(test_stop_with_uninterruptable_clients_connected) {
+ // This tests pre-THRIFT-2441 behavior: stopping the server blocks until clients
+ // disconnect.
- boost::dynamic_pointer_cast<TServerSocket>(pServer->getServerTransport())->
- setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
+ boost::dynamic_pointer_cast<TServerSocket>(pServer->getServerTransport())
+ ->setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
- startServer();
+ startServer();
- boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser);
- pClientSock1->open();
+ boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()),
+ autoSocketCloser);
+ pClientSock1->open();
- boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser);
- pClientSock2->open();
+ boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()),
+ autoSocketCloser);
+ pClientSock2->open();
- // Ensure they have been accepted
- blockUntilAccepted(2);
+ // Ensure they have been accepted
+ blockUntilAccepted(2);
- boost::thread t1(boost::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock1, milliseconds(250)));
- boost::thread t2(boost::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock2, milliseconds(250)));
+ boost::thread t1(boost::bind(&TServerIntegrationTestFixture::delayClose,
+ this,
+ pClientSock1,
+ milliseconds(250)));
+ boost::thread t2(boost::bind(&TServerIntegrationTestFixture::delayClose,
+ this,
+ pClientSock2,
+ milliseconds(250)));
- // Once the clients disconnect the server will stop
- stopServer();
- t1.join();
- t2.join();
+ // Once the clients disconnect the server will stop
+ stopServer();
+ t1.join();
+ t2.join();
}
-BOOST_AUTO_TEST_CASE(test_concurrent_client_limit)
-{
- startServer();
+BOOST_AUTO_TEST_CASE(test_concurrent_client_limit) {
+ startServer();
- BOOST_CHECK_EQUAL(INT64_MAX, pServer->getConcurrentClientLimit());
- pServer->setConcurrentClientLimit(2);
- BOOST_CHECK_EQUAL(0, pServer->getConcurrentClientCount());
- BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientLimit());
+ BOOST_CHECK_EQUAL(INT64_MAX, pServer->getConcurrentClientLimit());
+ pServer->setConcurrentClientLimit(2);
+ BOOST_CHECK_EQUAL(0, pServer->getConcurrentClientCount());
+ BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientLimit());
- boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser);
- pClientSock1->open();
- blockUntilAccepted(1);
- BOOST_CHECK_EQUAL(1, pServer->getConcurrentClientCount());
+ boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()),
+ autoSocketCloser);
+ pClientSock1->open();
+ blockUntilAccepted(1);
+ BOOST_CHECK_EQUAL(1, pServer->getConcurrentClientCount());
- boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser);
- pClientSock2->open();
- blockUntilAccepted(2);
- BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount());
+ boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()),
+ autoSocketCloser);
+ pClientSock2->open();
+ blockUntilAccepted(2);
+ BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount());
- // a third client cannot connect until one of the other two closes
- boost::thread t2(boost::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock2, milliseconds(250)));
- boost::shared_ptr<TSocket> pClientSock3(new TSocket("localhost", getServerPort()), autoSocketCloser);
- pClientSock2->open();
- blockUntilAccepted(2);
- BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount());
- BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCountHWM());
+ // a third client cannot connect until one of the other two closes
+ boost::thread t2(boost::bind(&TServerIntegrationTestFixture::delayClose,
+ this,
+ pClientSock2,
+ milliseconds(250)));
+ boost::shared_ptr<TSocket> pClientSock3(new TSocket("localhost", getServerPort()),
+ autoSocketCloser);
+ pClientSock2->open();
+ blockUntilAccepted(2);
+ BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount());
+ BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCountHWM());
- stopServer();
- t2.join();
+ stopServer();
+ t2.join();
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/lib/cpp/test/TServerSocketTest.cpp b/lib/cpp/test/TServerSocketTest.cpp
index 65f99f9..ae87ba8 100644
--- a/lib/cpp/test/TServerSocketTest.cpp
+++ b/lib/cpp/test/TServerSocketTest.cpp
@@ -29,44 +29,39 @@
using apache::thrift::transport::TTransport;
using apache::thrift::transport::TTransportException;
-BOOST_FIXTURE_TEST_SUITE ( TServerSocketTest, TestPortFixture )
+BOOST_FIXTURE_TEST_SUITE(TServerSocketTest, TestPortFixture)
-BOOST_AUTO_TEST_CASE( test_bind_to_address )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- accepted->close();
- sock1.close();
+BOOST_AUTO_TEST_CASE(test_bind_to_address) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ accepted->close();
+ sock1.close();
- std::cout << "An error message from getaddrinfo on the console is expected:" << std::endl;
- TServerSocket sock2("257.258.259.260", m_serverPort);
- BOOST_CHECK_THROW(sock2.listen(), TTransportException);
- sock2.close();
+ std::cout << "An error message from getaddrinfo on the console is expected:" << std::endl;
+ TServerSocket sock2("257.258.259.260", m_serverPort);
+ BOOST_CHECK_THROW(sock2.listen(), TTransportException);
+ sock2.close();
}
-BOOST_AUTO_TEST_CASE( test_listen_valid_port )
-{
- TServerSocket sock1(-1);
- TTRANSPORT_CHECK_THROW(sock1.listen(), TTransportException::BAD_ARGS);
+BOOST_AUTO_TEST_CASE(test_listen_valid_port) {
+ TServerSocket sock1(-1);
+ TTRANSPORT_CHECK_THROW(sock1.listen(), TTransportException::BAD_ARGS);
- TServerSocket sock2(65536);
- TTRANSPORT_CHECK_THROW(sock2.listen(), TTransportException::BAD_ARGS);
+ TServerSocket sock2(65536);
+ TTRANSPORT_CHECK_THROW(sock2.listen(), TTransportException::BAD_ARGS);
}
-BOOST_AUTO_TEST_CASE( test_close_before_listen )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.close();
+BOOST_AUTO_TEST_CASE(test_close_before_listen) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_get_port )
-{
- TServerSocket sock1("localHost", 888);
- BOOST_CHECK_EQUAL(888, sock1.getPort());
+BOOST_AUTO_TEST_CASE(test_get_port) {
+ TServerSocket sock1("localHost", 888);
+ BOOST_CHECK_EQUAL(888, sock1.getPort());
}
BOOST_AUTO_TEST_SUITE_END()
-
diff --git a/lib/cpp/test/TServerTransportTest.cpp b/lib/cpp/test/TServerTransportTest.cpp
index 09b2c59..2047337 100644
--- a/lib/cpp/test/TServerTransportTest.cpp
+++ b/lib/cpp/test/TServerTransportTest.cpp
@@ -26,37 +26,32 @@
using apache::thrift::transport::TTransport;
using apache::thrift::transport::TTransportException;
-BOOST_AUTO_TEST_SUITE ( TServerTransportTest )
+BOOST_AUTO_TEST_SUITE(TServerTransportTest)
-class TestTTransport : public TTransport
-{
-};
+class TestTTransport : public TTransport {};
-class TestTServerTransport : public TServerTransport
-{
+class TestTServerTransport : public TServerTransport {
public:
- TestTServerTransport() : valid_(true) {}
- void close() {}
- bool valid_;
+ TestTServerTransport() : valid_(true) {}
+ void close() {}
+ bool valid_;
+
protected:
- boost::shared_ptr<TTransport> acceptImpl()
- {
- return valid_ ? boost::shared_ptr<TestTTransport>(new TestTTransport) : boost::shared_ptr<TestTTransport>();
- }
+ boost::shared_ptr<TTransport> acceptImpl() {
+ return valid_ ? boost::shared_ptr<TestTTransport>(new TestTTransport)
+ : boost::shared_ptr<TestTTransport>();
+ }
};
-BOOST_AUTO_TEST_CASE( test_positive_accept )
-{
- TestTServerTransport uut;
- BOOST_CHECK(uut.accept());
+BOOST_AUTO_TEST_CASE(test_positive_accept) {
+ TestTServerTransport uut;
+ BOOST_CHECK(uut.accept());
}
-BOOST_AUTO_TEST_CASE( test_negative_accept )
-{
- TestTServerTransport uut;
- uut.valid_ = false;
- BOOST_CHECK_THROW(uut.accept(), TTransportException);
+BOOST_AUTO_TEST_CASE(test_negative_accept) {
+ TestTServerTransport uut;
+ uut.valid_ = false;
+ BOOST_CHECK_THROW(uut.accept(), TTransportException);
}
BOOST_AUTO_TEST_SUITE_END()
-
diff --git a/lib/cpp/test/TSocketInterruptTest.cpp b/lib/cpp/test/TSocketInterruptTest.cpp
index 4f6b2bc..02da3ee 100644
--- a/lib/cpp/test/TSocketInterruptTest.cpp
+++ b/lib/cpp/test/TSocketInterruptTest.cpp
@@ -33,122 +33,110 @@
using apache::thrift::transport::TTransport;
using apache::thrift::transport::TTransportException;
-BOOST_FIXTURE_TEST_SUITE ( TSocketInterruptTest, TestPortFixture )
+BOOST_FIXTURE_TEST_SUITE(TSocketInterruptTest, TestPortFixture)
-void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult)
-{
+void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult) {
+ uint8_t buf[4];
+ BOOST_CHECK_EQUAL(expectedResult, tt->read(buf, 4));
+}
+
+void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt) {
+ try {
uint8_t buf[4];
- BOOST_CHECK_EQUAL(expectedResult, tt->read(buf, 4));
+ tt->read(buf, 4);
+ BOOST_ERROR("should not have gotten here");
+ } catch (const TTransportException& tx) {
+ BOOST_CHECK_EQUAL(TTransportException::INTERRUPTED, tx.getType());
+ }
}
-void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt)
-{
- try
- {
- uint8_t buf[4];
- tt->read(buf, 4);
- BOOST_ERROR("should not have gotten here");
- }
- catch (const TTransportException& tx)
- {
- BOOST_CHECK_EQUAL(TTransportException::INTERRUPTED, tx.getType());
- }
+BOOST_AUTO_TEST_CASE(test_interruptable_child_read) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ // readThread is practically guaranteed to be blocking now
+ sock1.interruptChildren();
+ BOOST_CHECK_MESSAGE(readThread.try_join_for(boost::chrono::milliseconds(200)),
+ "server socket interruptChildren did not interrupt child read");
+ clientSock.close();
+ accepted->close();
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_interruptable_child_read )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted));
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
- // readThread is practically guaranteed to be blocking now
- sock1.interruptChildren();
- BOOST_CHECK_MESSAGE(readThread.try_join_for(boost::chrono::milliseconds(200)),
- "server socket interruptChildren did not interrupt child read");
- clientSock.close();
- accepted->close();
- sock1.close();
+BOOST_AUTO_TEST_CASE(test_non_interruptable_child_read) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ boost::thread readThread(boost::bind(readerWorker, accepted, 0));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ // readThread is practically guaranteed to be blocking here
+ sock1.interruptChildren();
+ BOOST_CHECK_MESSAGE(!readThread.try_join_for(boost::chrono::milliseconds(200)),
+ "server socket interruptChildren interrupted child read");
+
+ // only way to proceed is to have the client disconnect
+ clientSock.close();
+ readThread.join();
+ accepted->close();
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_non_interruptable_child_read )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- boost::thread readThread(boost::bind(readerWorker, accepted, 0));
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
- // readThread is practically guaranteed to be blocking here
- sock1.interruptChildren();
- BOOST_CHECK_MESSAGE(!readThread.try_join_for(boost::chrono::milliseconds(200)),
- "server socket interruptChildren interrupted child read");
-
- // only way to proceed is to have the client disconnect
- clientSock.close();
- readThread.join();
- accepted->close();
- sock1.close();
+BOOST_AUTO_TEST_CASE(test_cannot_change_after_listen) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.listen();
+ BOOST_CHECK_THROW(sock1.setInterruptableChildren(false), std::logic_error);
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_cannot_change_after_listen )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.listen();
- BOOST_CHECK_THROW(sock1.setInterruptableChildren(false), std::logic_error);
- sock1.close();
+void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult) {
+ BOOST_CHECK_EQUAL(expectedResult, tt->peek());
}
-void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult)
-{
- BOOST_CHECK_EQUAL(expectedResult, tt->peek());
+BOOST_AUTO_TEST_CASE(test_interruptable_child_peek) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ // peek() will return false if child is interrupted
+ boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ // peekThread is practically guaranteed to be blocking now
+ sock1.interruptChildren();
+ BOOST_CHECK_MESSAGE(peekThread.try_join_for(boost::chrono::milliseconds(200)),
+ "server socket interruptChildren did not interrupt child peek");
+ clientSock.close();
+ accepted->close();
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_interruptable_child_peek )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- // peek() will return false if child is interrupted
- boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
- // peekThread is practically guaranteed to be blocking now
- sock1.interruptChildren();
- BOOST_CHECK_MESSAGE(peekThread.try_join_for(boost::chrono::milliseconds(200)),
- "server socket interruptChildren did not interrupt child peek");
- clientSock.close();
- accepted->close();
- sock1.close();
-}
+BOOST_AUTO_TEST_CASE(test_non_interruptable_child_peek) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ // peek() will return false when remote side is closed
+ boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ // peekThread is practically guaranteed to be blocking now
+ sock1.interruptChildren();
+ BOOST_CHECK_MESSAGE(!peekThread.try_join_for(boost::chrono::milliseconds(200)),
+ "server socket interruptChildren interrupted child peek");
-BOOST_AUTO_TEST_CASE( test_non_interruptable_child_peek )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- // peek() will return false when remote side is closed
- boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
- // peekThread is practically guaranteed to be blocking now
- sock1.interruptChildren();
- BOOST_CHECK_MESSAGE(!peekThread.try_join_for(boost::chrono::milliseconds(200)),
- "server socket interruptChildren interrupted child peek");
-
- // only way to proceed is to have the client disconnect
- clientSock.close();
- peekThread.join();
- accepted->close();
- sock1.close();
+ // only way to proceed is to have the client disconnect
+ clientSock.close();
+ peekThread.join();
+ accepted->close();
+ sock1.close();
}
BOOST_AUTO_TEST_SUITE_END()
-
diff --git a/lib/cpp/test/TTransportCheckThrow.h b/lib/cpp/test/TTransportCheckThrow.h
index 3b212e1..92277b4 100644
--- a/lib/cpp/test/TTransportCheckThrow.h
+++ b/lib/cpp/test/TTransportCheckThrow.h
@@ -19,15 +19,26 @@
#pragma once
-#define TTRANSPORT_CHECK_THROW(_CALL, _TYPE) \
- { bool caught = false; \
- try { (_CALL); } \
- catch (TTransportException& ex) { BOOST_CHECK_EQUAL(ex.getType(), _TYPE); caught = true; } \
- BOOST_CHECK_MESSAGE(caught, "expected TTransportException but nothing was thrown"); }
+#define TTRANSPORT_CHECK_THROW(_CALL, _TYPE) \
+ { \
+ bool caught = false; \
+ try { \
+ (_CALL); \
+ } catch (TTransportException & ex) { \
+ BOOST_CHECK_EQUAL(ex.getType(), _TYPE); \
+ caught = true; \
+ } \
+ BOOST_CHECK_MESSAGE(caught, "expected TTransportException but nothing was thrown"); \
+ }
-#define TTRANSPORT_REQUIRE_THROW(_CALL, _TYPE) \
- { bool caught = false; \
- try { (_CALL); } \
- catch (TTransportException& ex) { BOOST_REQUIRE_EQUAL(ex.getType(), _TYPE); caught = true; } \
- BOOST_REQUIRE_MESSAGE(caught, "expected TTransportException but nothing was thrown"); }
-
+#define TTRANSPORT_REQUIRE_THROW(_CALL, _TYPE) \
+ { \
+ bool caught = false; \
+ try { \
+ (_CALL); \
+ } catch (TTransportException & ex) { \
+ BOOST_REQUIRE_EQUAL(ex.getType(), _TYPE); \
+ caught = true; \
+ } \
+ BOOST_REQUIRE_MESSAGE(caught, "expected TTransportException but nothing was thrown"); \
+ }
diff --git a/lib/cpp/test/TestPortFixture.h b/lib/cpp/test/TestPortFixture.h
index 5b27e5e..5af47d6 100644
--- a/lib/cpp/test/TestPortFixture.h
+++ b/lib/cpp/test/TestPortFixture.h
@@ -21,16 +21,13 @@
#include <cstdlib>
-class TestPortFixture
-{
- public:
- TestPortFixture()
- {
- const char *spEnv = std::getenv("THRIFT_TEST_PORT");
- m_serverPort = (spEnv) ? atoi(spEnv) : 9090;
- }
+class TestPortFixture {
+public:
+ TestPortFixture() {
+ const char* spEnv = std::getenv("THRIFT_TEST_PORT");
+ m_serverPort = (spEnv) ? atoi(spEnv) : 9090;
+ }
- protected:
- int m_serverPort;
+protected:
+ int m_serverPort;
};
-
diff --git a/lib/cpp/test/TypedefTest.cpp b/lib/cpp/test/TypedefTest.cpp
index eb2f743..24e9265 100644
--- a/lib/cpp/test/TypedefTest.cpp
+++ b/lib/cpp/test/TypedefTest.cpp
@@ -24,4 +24,5 @@
BOOST_STATIC_ASSERT((boost::is_same<int32_t, thrift::test::MyInt32>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::string, thrift::test::MyString>::value));
-BOOST_STATIC_ASSERT((boost::is_same<thrift::test::TypedefTestStruct, thrift::test::MyStruct>::value));
+BOOST_STATIC_ASSERT(
+ (boost::is_same<thrift::test::TypedefTestStruct, thrift::test::MyStruct>::value));
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index 2a89a28..fa5b635 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -51,7 +51,6 @@
// Length of argv[0] - Length of script dir
#define EXECUTABLE_FILE_NAME_LENGTH 19
-
// Current time, microseconds since the epoch
uint64_t now() {
int64_t ret;
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 2705064..526cb0b 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -418,7 +418,8 @@
cob(res);
}
- virtual void testBinary(tcxx::function<void(std::string const& _return)> cob, const std::string& thing) {
+ virtual void testBinary(tcxx::function<void(std::string const& _return)> cob,
+ const std::string& thing) {
std::string res;
_delegate->testBinary(res, thing);
cob(res);
diff --git a/test/crossrunner/collect.py b/test/crossrunner/collect.py
index 6c771b3..145afef 100644
--- a/test/crossrunner/collect.py
+++ b/test/crossrunner/collect.py
@@ -36,7 +36,7 @@
# (e.g. binary:accel) where test is run for any matching "spec" while actual
# argument passed to test executable is "impl".
# Otherwise "spec" is equivalent to "spec:spec" pair.
-# (e.g. "binary" is equivalent to "binary:bianry" in tests.json)
+# (e.g. "binary" is equivalent to "binary:binary" in tests.json)
#
VALID_JSON_KEYS = [
'name', # name of the library, typically a language name