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
adec01cc
Commit
adec01cc
authored
Mar 28, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
health_check_using_rpc: change async Appcheck to sync
parent
938f2e85
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
28 deletions
+6
-28
health_check.cpp
src/brpc/details/health_check.cpp
+6
-28
No files found.
src/brpc/details/health_check.cpp
View file @
adec01cc
...
...
@@ -70,7 +70,6 @@ class HealthCheckManager {
public
:
static
void
StartCheck
(
SocketId
id
,
int64_t
check_interval_s
);
static
void
*
AppCheck
(
void
*
arg
);
static
void
RunAppCheck
(
void
*
arg
);
};
void
HealthCheckManager
::
StartCheck
(
SocketId
id
,
int64_t
check_interval_s
)
{
...
...
@@ -110,17 +109,6 @@ void* HealthCheckManager::AppCheck(void* arg) {
return
NULL
;
}
void
HealthCheckManager
::
RunAppCheck
(
void
*
arg
)
{
bthread_t
th
=
0
;
int
rc
=
bthread_start_background
(
&
th
,
&
BTHREAD_ATTR_NORMAL
,
AppCheck
,
arg
);
if
(
rc
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to start AppCheck"
;
AppCheck
(
arg
);
return
;
}
}
void
OnAppHealthCheckDone
::
Run
()
{
std
::
unique_ptr
<
OnAppHealthCheckDone
>
self_guard
(
this
);
SocketUniquePtr
ptr
;
...
...
@@ -145,23 +133,13 @@ void OnAppHealthCheckDone::Run() {
int64_t
sleep_time_ms
=
last_check_time_ms
+
interval_s
*
1000
-
butil
::
gettimeofday_ms
();
if
(
sleep_time_ms
>
0
)
{
const
timespec
abstime
=
butil
::
milliseconds_from_now
(
sleep_time_ms
);
bthread_timer_t
timer_id
;
const
int
rc
=
bthread_timer_add
(
&
timer_id
,
abstime
,
HealthCheckManager
::
RunAppCheck
,
this
);
if
(
rc
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to add timer for RunAppCheck"
;
// TODO(zhujiashun): we need to handle the case when timer fails.
// In most situations, the possibility of this case is quite small,
// so currently we just keep sending the hc call.
HealthCheckManager
::
AppCheck
(
this
);
return
;
}
}
else
{
// the time of next call has passed, just AppCheck immediately
HealthCheckManager
::
AppCheck
(
this
);
// TODO(zhujiashun): we need to handle the case when timer fails
// and bthread_usleep returns immediately. In most situations,
// the possibility of this case is quite small, so currently we
// just keep sending the hc call.
bthread_usleep
(
sleep_time_ms
*
1000
);
}
self_guard
.
release
(
);
HealthCheckManager
::
AppCheck
(
self_guard
.
release
()
);
}
class
HealthCheckTask
:
public
PeriodicTask
{
...
...
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