Commit 2b5c4c26 authored by gejun's avatar gejun

patch left rejected & elaborate tools/patch_from_svn

Change-Id: Ib2a64d5bdc7864e817885c9112cb30d3b47d5c2a
parent 961492db
......@@ -14,6 +14,7 @@
#include "base/scoped_lock.h"
#include "base/endpoint.h"
#include "bthread/bthread.h" // bthread_usleep
#include "brpc/reloadable_flags.h"
#include "brpc/details/http_message.h"
......
......@@ -32,7 +32,6 @@ extern "C" {
void bthread_assign_data(void* data) __THROW;
}
namespace brpc {
int is_failed_after_queries(const http_parser* parser);
......@@ -398,8 +397,7 @@ void SerializeHttpRequest(base::IOBuf* /*not used*/,
// Serialize content as json
std::string err;
json2pb::Pb2JsonOptions opt;
opt.enum_option = (FLAGS_pb_enum_as_number
? json2pb::OUTPUT_ENUM_BY_NUMBER
opt.enum_option = (FLAGS_pb_enum_as_number ? json2pb::OUTPUT_ENUM_BY_NUMBER
: json2pb::OUTPUT_ENUM_BY_NAME);
if (!json2pb::ProtoMessageToJson(*request, &wrapper, opt, &err)) {
cntl->request_attachment().clear();
......@@ -613,8 +611,7 @@ static void SendHttpResponse(Controller *cntl,
} else {
std::string err;
json2pb::Pb2JsonOptions opt;
opt.enum_option = (FLAGS_pb_enum_as_number
? json2pb::OUTPUT_ENUM_BY_NUMBER
opt.enum_option = (FLAGS_pb_enum_as_number ? json2pb::OUTPUT_ENUM_BY_NUMBER
: json2pb::OUTPUT_ENUM_BY_NAME);
if (json2pb::ProtoMessageToJson(*res, &wrapper, opt, &err)) {
// Set content-type if user did not
......@@ -1093,7 +1090,8 @@ void ProcessHttpRequest(InputMessageBase *msg) {
}
}
// Tag the bthread with this server's key for thread_local_data().
// Tag the bthread with this server's key for
// thread_local_data().
if (server->thread_local_options().thread_local_data_factory) {
bthread_assign_data((void*)&server->thread_local_options());
}
......@@ -1149,7 +1147,7 @@ void ProcessHttpRequest(InputMessageBase *msg) {
accessor.set_method(md);
cntl->http_request().Swap(http_imsg->header());
cntl->request_attachment().swap(http_imsg->body());
google::protobuf::Closure* done = ::brpc::NewCallback<
google::protobuf::Closure* done = brpc::NewCallback<
Controller*, const google::protobuf::Message*,
const google::protobuf::Message*, const Server*,
MethodStatus *, long>(
......@@ -1287,7 +1285,7 @@ void ProcessHttpRequest(InputMessageBase *msg) {
http_imsg.reset(); // optional, just release resourse ASAP
google::protobuf::Closure* done = ::brpc::NewCallback<
google::protobuf::Closure* done = brpc::NewCallback<
Controller*, const google::protobuf::Message*,
const google::protobuf::Message*, const Server*,
MethodStatus *, long>(
......
......@@ -12,25 +12,44 @@
namespace brpc {
// Inherit this class to customize the error code that should be retried.
// Inherit this class to customize when the RPC should be retried.
class RetryPolicy {
public:
virtual ~RetryPolicy();
// Returns true if the RPC represented by `controller' should be retried.
// Example:
// By default, HTTP errors are not retried. And you need to retry for
// [Example]
// By default, HTTP errors are not retried, but you need to retry
// HTTP_STATUS_FORBIDDEN in your app. You can implement the RetryPolicy
// as follows:
//
// class MyRetryPolicy : public brpc::RetryPolicy {
// public:
// bool DoRetry(const brpc::Controller* cntl) const {
// if (cntl->ErrorCode() == 0) { // don't retry successful RPC
// return false;
// }
// if (cntl->ErrorCode() == brpc::EHTTP && // http errors
// cntl->http_response().status_code() == brpc::HTTP_STATUS_FORBIDDEN) {
// return true;
// }
// // Leave other cases to baidu-rpc.
// // Leave other cases to default.
// return brpc::DefaultRetryPolicy()->DoRetry(cntl);
// }
// };
//
// You can retry unqualified responses even if the RPC was successful
// class MyRetryPolicy : public brpc::RetryPolicy {
// public:
// bool DoRetry(const brpc::Controller* cntl) const {
// if (cntl->ErrorCode() == 0) { // successful RPC
// if (!is_qualified(cntl->response())) {
// cntl->response()->Clear(); // reset the response
// return true;
// }
// return false;
// }
// // Leave other cases to default.
// return brpc::DefaultRetryPolicy()->DoRetry(cntl);
// }
// };
......
......@@ -5,6 +5,20 @@ if [ -z "$1" ]; then
exit 1
fi
cat $1 |sed -e 's/src\/baidu\/rpc\//brpc\//g' \
-e 's/\<baidu\/rpc\//brpc\//g' \
-e 's/brpc\/test\/test_\(.*\)\.cpp/test\/brpc_\1_unittest.cpp/g' \
-e 's/\<namespace \+baidu *{/namespace brpc {/g' \
-e 's/\<namespace \+rpc *{//g' \
-e 's/} *\/\/ \+namespace \+baidu/} \/\/ namespace brpc/g' \
-e 's/} *\/\/ \+namespace \+rpc\>//g' \
-e 's/\<baidu::rpc::/brpc::/g' \
-e 's/\<rpc::/brpc::/g' \
-e 's/\<BAIDU_RPC_/BRPC_/g' \
-e 's/TEST_F(HttpMessageTest/TEST(HttpMessageTest/g' \
-e 's/TEST_F(URITest/TEST(URITest/g' \
-e 's/<bthread\.h>/\"bthread\/bthread.h\"/g' \
-e 's/<bthread_\(.*\)\.h>/\"bthread\/\1.h\"/g' \
-e 's/<\(brpc\/[^>]*\)>/"\1"/g' \
-e 's/<\(bvar\/[^>]*\)>/"\1"/g' \
-e 's/<\(base\/[^>]*\)>/"\1"/g' \
-e 's/<\(bthread\/[^>]*\)>/"\1"/g' \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment