Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
efb67135
Commit
efb67135
authored
Aug 02, 2017
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch svn r34954
Change-Id: I8bcac6c96c0e4dc7bddafaf3bf4408c0af96de5c
parent
dd6ef191
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
13 deletions
+18
-13
global.cpp
brpc/global.cpp
+1
-6
trackme.cpp
brpc/trackme.cpp
+13
-4
trackme.h
brpc/trackme.h
+1
-1
trackme.proto
brpc/trackme.proto
+2
-2
patch_from_svn
tools/patch_from_svn
+1
-0
No files found.
brpc/global.cpp
View file @
efb67135
...
...
@@ -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
...
...
brpc/trackme.cpp
View file @
efb67135
...
...
@@ -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
)
{
...
...
brpc/trackme.h
View file @
efb67135
...
...
@@ -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
...
...
brpc/trackme.proto
View file @
efb67135
...
...
@@ -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
...
...
tools/patch_from_svn
View file @
efb67135
...
...
@@ -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'
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment