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
a73bbdf9
Commit
a73bbdf9
authored
Nov 19, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine code
parent
e9fe8b1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
22 deletions
+21
-22
discovery_naming_service.cpp
src/brpc/policy/discovery_naming_service.cpp
+19
-19
discovery_naming_service.h
src/brpc/policy/discovery_naming_service.h
+2
-3
No files found.
src/brpc/policy/discovery_naming_service.cpp
View file @
a73bbdf9
...
...
@@ -261,19 +261,21 @@ void* DiscoveryClient::PeriodicRenew(void* arg) {
while
(
!
bthread_stopped
(
bthread_self
()))
{
if
(
consecutive_renew_error
==
FLAGS_discovery_reregister_threshold
)
{
LOG
(
WARNING
)
<<
"Reregister since discovery renew error threshold reached"
;
std
::
unique_lock
<
butil
::
Mutex
>
mu
(
d
->
_mutex
);
switch
(
d
->
_state
)
{
case
INIT
:
CHECK
(
false
)
<<
"Impossible"
;
return
NULL
;
case
REGISTERING
:
case
REGISTERED
:
break
;
case
CANCELED
:
return
NULL
;
default
:
CHECK
(
false
)
<<
"Impossible"
;
return
NULL
;
{
std
::
unique_lock
<
butil
::
Mutex
>
mu
(
d
->
_mutex
);
switch
(
d
->
_state
)
{
case
INIT
:
CHECK
(
false
)
<<
"Impossible"
;
return
NULL
;
case
REGISTERING
:
case
REGISTERED
:
break
;
case
CANCELED
:
return
NULL
;
default
:
CHECK
(
false
)
<<
"Impossible"
;
return
NULL
;
}
}
// Do register until succeed or Cancel is called
while
(
!
bthread_stopped
(
bthread_self
()))
{
...
...
@@ -303,8 +305,7 @@ void* DiscoveryClient::PeriodicRenew(void* arg) {
continue
;
}
std
::
string
error_text
;
int
rc
=
ParseCommonResult
(
cntl
.
response_attachment
(),
&
error_text
);
if
(
rc
!=
0
)
{
if
(
ParseCommonResult
(
cntl
.
response_attachment
(),
&
error_text
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to renew "
<<
d
->
_hostname
<<
" to "
<<
d
->
_appid
<<
": "
<<
error_text
;
consecutive_renew_error
++
;
...
...
@@ -412,8 +413,7 @@ int DiscoveryClient::do_register() {
return
-
1
;
}
std
::
string
error_text
;
int
rc
=
ParseCommonResult
(
cntl
.
response_attachment
(),
&
error_text
);
if
(
rc
!=
0
)
{
if
(
ParseCommonResult
(
cntl
.
response_attachment
(),
&
error_text
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to register "
<<
_hostname
<<
" to "
<<
_appid
<<
": "
<<
error_text
;
return
-
1
;
...
...
@@ -439,6 +439,7 @@ int DiscoveryClient::Cancel() {
return
-
1
;
}
}
CHECK_NE
(
_th
,
INVALID_BTHREAD
);
bthread_stop
(
_th
);
bthread_join
(
_th
,
NULL
);
return
do_cancel
();
...
...
@@ -462,8 +463,7 @@ int DiscoveryClient::do_cancel() {
return
-
1
;
}
std
::
string
error_text
;
int
rc
=
ParseCommonResult
(
cntl
.
response_attachment
(),
&
error_text
);
if
(
rc
!=
0
)
{
if
(
ParseCommonResult
(
cntl
.
response_attachment
(),
&
error_text
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to cancel "
<<
_hostname
<<
" in "
<<
_appid
<<
": "
<<
error_text
;
return
-
1
;
...
...
src/brpc/policy/discovery_naming_service.h
View file @
a73bbdf9
...
...
@@ -51,8 +51,8 @@ struct DiscoveryRegisterParam {
};
// ONE DiscoveryClient corresponds to ONE service instance.
// If your program has multiple
instances to register, you need multiple
// DiscoveryClient.
// If your program has multiple
service instances to register,
//
you need multiple
DiscoveryClient.
class
DiscoveryClient
{
public
:
DiscoveryClient
();
...
...
@@ -87,7 +87,6 @@ private:
std
::
string
_metadata
;
};
}
// namespace policy
}
// namespace brpc
...
...
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