Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
4989e6e4
Commit
4989e6e4
authored
Mar 01, 2017
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Don't call functions which are not async-signal-safe
.. after fork but before execv in multithreaded process.
parent
d4963bcd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
22 deletions
+22
-22
src/shrpx_exec.cc
src/shrpx_exec.cc
+7
-6
src/shrpx_signal.cc
src/shrpx_signal.cc
+11
-12
src/shrpx_signal.h
src/shrpx_signal.h
+4
-4
No files found.
src/shrpx_exec.cc
View file @
4989e6e4
...
...
@@ -76,14 +76,16 @@ int exec_read_command(Process &proc, char *const argv[]) {
auto
pid
=
fork
();
if
(
pid
==
0
)
{
// This is multithreaded program, and we are allowed to use only
// async-signal-safe functions here.
// child process
shrpx_signal_unset_worker_proc_ign_handler
();
rv
=
shrpx_signal_unblock_all
();
if
(
rv
!=
0
)
{
auto
error
=
errno
;
LOG
(
FATAL
)
<<
"Unblocking all signals failed: errno="
<<
error
;
constexpr
char
msg
[]
=
"Unblocking all signals failed
\n
"
;
write
(
STDERR_FILENO
,
msg
,
str_size
(
msg
));
nghttp2_Exit
(
EXIT_FAILURE
);
}
...
...
@@ -92,9 +94,8 @@ int exec_read_command(Process &proc, char *const argv[]) {
rv
=
execv
(
argv
[
0
],
argv
);
if
(
rv
==
-
1
)
{
auto
error
=
errno
;
LOG
(
ERROR
)
<<
"Could not execute command: "
<<
argv
[
0
]
<<
", execve() faild, errno="
<<
error
;
constexpr
char
msg
[]
=
"Could not execute command
\n
"
;
write
(
STDERR_FILENO
,
msg
,
str_size
(
msg
));
nghttp2_Exit
(
EXIT_FAILURE
);
}
// unreachable
...
...
src/shrpx_signal.cc
View file @
4989e6e4
...
...
@@ -94,7 +94,7 @@ int shrpx_signal_set(sigset_t *set) {
namespace
{
template
<
typename
Signals
>
void
signal_set_handler
(
void
(
*
handler
)(
int
),
Signals
&&
sigs
)
{
int
signal_set_handler
(
void
(
*
handler
)(
int
),
Signals
&&
sigs
)
{
struct
sigaction
act
{};
act
.
sa_handler
=
handler
;
sigemptyset
(
&
act
.
sa_mask
);
...
...
@@ -102,11 +102,10 @@ void signal_set_handler(void (*handler)(int), Signals &&sigs) {
for
(
auto
sig
:
sigs
)
{
rv
=
sigaction
(
sig
,
&
act
,
nullptr
);
if
(
rv
!=
0
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"sigaction() with signal "
<<
sig
<<
" failed: errno="
<<
error
;
return
-
1
;
}
}
return
0
;
}
}
// namespace
...
...
@@ -120,20 +119,20 @@ constexpr auto worker_proc_ign_signals =
GRACEFUL_SHUTDOWN_SIGNAL
,
RELOAD_SIGNAL
,
SIGPIPE
}};
}
// namespace
void
shrpx_signal_set_master_proc_ign_handler
()
{
signal_set_handler
(
SIG_IGN
,
master_proc_ign_signals
);
int
shrpx_signal_set_master_proc_ign_handler
()
{
return
signal_set_handler
(
SIG_IGN
,
master_proc_ign_signals
);
}
void
shrpx_signal_unset_master_proc_ign_handler
()
{
signal_set_handler
(
SIG_DFL
,
master_proc_ign_signals
);
int
shrpx_signal_unset_master_proc_ign_handler
()
{
return
signal_set_handler
(
SIG_DFL
,
master_proc_ign_signals
);
}
void
shrpx_signal_set_worker_proc_ign_handler
()
{
signal_set_handler
(
SIG_IGN
,
worker_proc_ign_signals
);
int
shrpx_signal_set_worker_proc_ign_handler
()
{
return
signal_set_handler
(
SIG_IGN
,
worker_proc_ign_signals
);
}
void
shrpx_signal_unset_worker_proc_ign_handler
()
{
signal_set_handler
(
SIG_DFL
,
worker_proc_ign_signals
);
int
shrpx_signal_unset_worker_proc_ign_handler
()
{
return
signal_set_handler
(
SIG_DFL
,
worker_proc_ign_signals
);
}
}
// namespace shrpx
src/shrpx_signal.h
View file @
4989e6e4
...
...
@@ -49,11 +49,11 @@ int shrpx_signal_unblock_all();
// -1. The errno will indicate the error.
int
shrpx_signal_set
(
sigset_t
*
set
);
void
shrpx_signal_set_master_proc_ign_handler
();
void
shrpx_signal_unset_master_proc_ign_handler
();
int
shrpx_signal_set_master_proc_ign_handler
();
int
shrpx_signal_unset_master_proc_ign_handler
();
void
shrpx_signal_set_worker_proc_ign_handler
();
void
shrpx_signal_unset_worker_proc_ign_handler
();
int
shrpx_signal_set_worker_proc_ign_handler
();
int
shrpx_signal_unset_worker_proc_ign_handler
();
}
// namespace shrpx
...
...
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