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
30b1d7f2
Commit
30b1d7f2
authored
Jan 31, 2018
by
osdaniellee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add SIGTERM handle for brpc controller
parent
d28ae56f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
8 deletions
+27
-8
controller.cpp
src/brpc/controller.cpp
+27
-8
No files found.
src/brpc/controller.cpp
View file @
30b1d7f2
...
...
@@ -1374,27 +1374,46 @@ typedef sighandler_t SignalHandler;
#endif
static
volatile
bool
s_signal_quit
=
false
;
static
SignalHandler
s_prev_handler
=
NULL
;
static
SignalHandler
s_prev_sigint_handler
=
NULL
;
static
SignalHandler
s_prev_sigterm_handler
=
NULL
;
static
void
quit_handler
(
int
signo
)
{
s_signal_quit
=
true
;
if
(
s_prev_handler
)
{
s_prev_handler
(
signo
);
s_signal_quit
=
true
;
if
(
SIGINT
==
signo
&&
s_prev_sigint_handler
)
{
s_prev_sigint_handler
(
signo
);
}
if
(
SIGTERM
==
signo
&&
s_prev_sigterm_handler
)
{
s_prev_sigterm_handler
(
signo
);
}
}
static
pthread_once_t
register_quit_signal_once
=
PTHREAD_ONCE_INIT
;
static
void
RegisterQuitSignalOrDie
()
{
// Not thread-safe.
const
SignalHandler
prev
=
signal
(
SIGINT
,
quit_handler
);
if
(
prev
!=
SIG_DFL
&&
SignalHandler
prev
=
signal
(
SIGINT
,
quit_handler
);
if
(
prev
!=
SIG_DFL
&&
prev
!=
SIG_IGN
)
{
// shell may install SIGINT of background jobs with SIG_IGN
if
(
prev
==
SIG_ERR
)
{
LOG
(
ERROR
)
<<
"Fail to register SIGINT, abort"
;
abort
();
}
else
{
s_prev_handler
=
prev
;
}
else
{
s_prev_
sigint_
handler
=
prev
;
LOG
(
WARNING
)
<<
"SIGINT was installed with "
<<
prev
;
}
}
prev
=
signal
(
SIGTERM
,
quit_handler
);
if
(
prev
!=
SIG_DFL
&&
prev
!=
SIG_IGN
)
{
// shell may install SIGTERM of background jobs with SIG_IGN
if
(
prev
==
SIG_ERR
)
{
LOG
(
ERROR
)
<<
"Fail to register SIGTERM, abort"
;
abort
();
}
else
{
s_prev_sigterm_handler
=
prev
;
LOG
(
WARNING
)
<<
"SIGTERM was installed with "
<<
prev
;
}
}
}
bool
IsAskedToQuit
()
{
...
...
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