Commit efb67135 authored by gejun's avatar gejun

patch svn r34954

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