Commit efb67135 authored by gejun's avatar gejun

patch svn r34954

Change-Id: I8bcac6c96c0e4dc7bddafaf3bf4408c0af96de5c
parent dd6ef191
......@@ -70,9 +70,6 @@ using namespace policy;
const char* const DUMMY_SERVER_PORT_FILE = "dummy_server.port";
DEFINE_bool(enable_trackme, true,
"Ping brpc.baidu.com periodically to check out latest bugs");
struct GlobalExtensions {
GlobalExtensions()
: ch_mh_lb(MurmurHash32)
......@@ -187,9 +184,7 @@ static void* GlobalUpdate(void*) {
}
last_time_us = base::gettimeofday_us();
if (FLAGS_enable_trackme) {
TrackMe();
}
TrackMe();
if (!IsDummyServerRunning()
&& g_running_server_count.load(base::memory_order_relaxed) == 0
......
......@@ -19,10 +19,16 @@
namespace brpc {
#ifdef BAIDU_INTERNAL
DEFINE_string(trackme_server, "http://brpc.baidu.com:8765",
"Where the TrackMe requests are sent to");
#else
DEFINE_string(trackme_server, "", "Where the TrackMe requests are sent to");
#endif
static const int32_t TRACKME_MIN_INTERVAL = 30;
static const int32_t TRACKME_MAX_INTERVAL = 600;
static int32_t s_trackme_interval = TRACKME_MIN_INTERVAL;
static const char* const TRACKME_SERVER = "http://brpc.baidu.com:8877";
// Protecting global vars on trackme
static pthread_mutex_t g_trackme_mutex = PTHREAD_MUTEX_INITIALIZER;
// For contacting with trackme_server.
......@@ -113,7 +119,7 @@ void SetTrackMeAddress(base::EndPoint pt) {
static void HandleTrackMeResponse(Controller* cntl, TrackMeResponse* res) {
if (cntl->Failed()) {
RPC_VLOG << "Fail to access " << TRACKME_SERVER << ", " << cntl->ErrorText();
RPC_VLOG << "Fail to access " << FLAGS_trackme_server << ", " << cntl->ErrorText();
} else {
BugInfo cur_info;
cur_info.severity = res->severity();
......@@ -180,8 +186,8 @@ static void TrackMeNow(std::unique_lock<pthread_mutex_t>& mu) {
ChannelOptions opt;
// keep #connections on server-side low
opt.connection_type = CONNECTION_TYPE_SHORT;
if (chan->Init(TRACKME_SERVER, "c_murmurhash", &opt) != 0) {
LOG(WARNING) << "Fail to connect to " << TRACKME_SERVER;
if (chan->Init(FLAGS_trackme_server.c_str(), "c_murmurhash", &opt) != 0) {
LOG(WARNING) << "Fail to connect to " << FLAGS_trackme_server;
delete chan;
return;
}
......@@ -203,6 +209,9 @@ static void TrackMeNow(std::unique_lock<pthread_mutex_t>& mu) {
// Called in global.cpp
// [Thread-safe] supposed to be called in low frequency.
void TrackMe() {
if (FLAGS_trackme_server.empty()) {
return;
}
int64_t now = base::gettimeofday_us();
std::unique_lock<pthread_mutex_t> mu(g_trackme_mutex);
if (g_trackme_last_time == 0) {
......
......@@ -19,7 +19,7 @@ namespace brpc {
void SetTrackMeAddress(base::EndPoint pt);
// Call this function every second (or every several seconds) to send
// TrackMeRequest to trackme_server every TRACKME_INTERVAL seconds.
// TrackMeRequest to -trackme_server every TRACKME_INTERVAL seconds.
void TrackMe();
} // namespace brpc
......
......@@ -4,7 +4,7 @@ option cc_generic_services=true;
package brpc;
// The request sent to brpc.baidu.com.
// The request sent to -trackme_server
message TrackMeRequest {
// the svn revision when baidu-rp being compiled, which will be checked
// by server to tell if the version contains bugs
......@@ -18,7 +18,7 @@ enum TrackMeSeverity {
TrackMeFatal = 2;
};
// The response from brpc.baidu.com
// The response from -trackme_server
message TrackMeResponse {
// Print an ERROR log with error_text when severity=TrackMeFatal
// Print a WARNING log with error_text when severity=TrackMeWarning
......
......@@ -14,6 +14,7 @@ cat $1 |sed -e 's/src\/baidu\/rpc\//brpc\//g' \
-e 's/\<baidu::rpc::/brpc::/g' \
-e 's/\<rpc::/brpc::/g' \
-e 's/\<BAIDU_RPC_/BRPC_/g' \
-e 's/\<protocol\/\(.*\)\.proto/\1.proto/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' \
......
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