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
fb49182c
Commit
fb49182c
authored
Jul 31, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Move original_argv, argv, argc, and cmdcfgs to StartupConfig
parent
b9b648e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
30 deletions
+37
-30
src/shrpx.cc
src/shrpx.cc
+37
-26
src/shrpx_config.h
src/shrpx_config.h
+0
-4
No files found.
src/shrpx.cc
View file @
fb49182c
...
...
@@ -130,6 +130,25 @@ constexpr auto ENV_ACCEPT_PREFIX = StringRef::from_lit("NGHTTPX_ACCEPT_");
#endif
#endif
// This configuration is fixed at the first startup of the main
// process, and does not change after subsequent reloadings.
struct
StartupConfig
{
// This contains all options given in command-line.
std
::
vector
<
std
::
pair
<
StringRef
,
StringRef
>>
cmdcfgs
;
// The current working directory where this process started.
char
*
cwd
;
// The pointer to original argv (not sure why we have this?)
char
**
original_argv
;
// The pointer to argv, this is a deep copy of original argv.
char
**
argv
;
// The number of elements in argv.
int
argc
;
};
namespace
{
StartupConfig
suconfig
;
}
// namespace
struct
InheritedAddr
{
// IP address if TCP socket. Otherwise, UNIX domain socket path.
ImmutableString
host
;
...
...
@@ -144,12 +163,6 @@ namespace {
std
::
random_device
rd
;
}
// namespace
namespace
{
// This contains all options given in command-line. Make it static so
// that we can use it in reloading.
std
::
vector
<
std
::
pair
<
StringRef
,
StringRef
>>
cmdcfgs
;
}
// namespace
namespace
{
void
signal_cb
(
struct
ev_loop
*
loop
,
ev_signal
*
w
,
int
revents
);
}
// namespace
...
...
@@ -388,21 +401,21 @@ void exec_binary(WorkerProcess *wp) {
_Exit
(
EXIT_FAILURE
);
}
auto
exec_path
=
util
::
get_exec_path
(
get_config
()
->
argc
,
get_config
()
->
argv
,
get_config
()
->
cwd
);
auto
exec_path
=
util
::
get_exec_path
(
suconfig
.
argc
,
suconfig
.
argv
,
suconfig
.
cwd
);
if
(
!
exec_path
)
{
LOG
(
ERROR
)
<<
"Could not resolve the executable path"
;
_Exit
(
EXIT_FAILURE
);
}
auto
argv
=
make_unique
<
char
*
[]
>
(
get_config
()
->
argc
+
1
);
auto
argv
=
make_unique
<
char
*
[]
>
(
suconfig
.
argc
+
1
);
argv
[
0
]
=
exec_path
;
for
(
int
i
=
1
;
i
<
get_config
()
->
argc
;
++
i
)
{
argv
[
i
]
=
get_config
()
->
argv
[
i
];
for
(
int
i
=
1
;
i
<
suconfig
.
argc
;
++
i
)
{
argv
[
i
]
=
suconfig
.
argv
[
i
];
}
argv
[
get_config
()
->
argc
]
=
nullptr
;
argv
[
suconfig
.
argc
]
=
nullptr
;
size_t
envlen
=
0
;
for
(
char
**
p
=
environ
;
*
p
;
++
p
,
++
envlen
)
...
...
@@ -2504,19 +2517,15 @@ void reload_config(WorkerProcess *wp) {
fill_default_config
(
new_config
.
get
());
new_config
->
conf_path
=
cur_config
->
conf_path
;
new_config
->
argc
=
cur_config
->
argc
;
new_config
->
argv
=
cur_config
->
argv
;
new_config
->
original_argv
=
cur_config
->
original_argv
;
new_config
->
cwd
=
cur_config
->
cwd
;
// daemon option is ignored here.
new_config
->
daemon
=
cur_config
->
daemon
;
rv
=
process_options
(
new_config
.
get
(),
cmdcfgs
);
rv
=
process_options
(
new_config
.
get
(),
suconfig
.
cmdcfgs
);
if
(
rv
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed to process new configuration"
;
return
;
}
// daemon option is ignored here.
auto
iaddrs
=
get_inherited_addr_from_config
(
cur_config
);
if
(
create_acceptor_socket
(
new_config
.
get
(),
iaddrs
)
!=
0
)
{
...
...
@@ -2582,28 +2591,30 @@ int main(int argc, char **argv) {
// log errors/warnings while reading configuration files.
reopen_log_files
();
mod_config
()
->
original_argv
=
argv
;
suconfig
.
original_argv
=
argv
;
// We have to copy argv, since getopt_long may change its content.
mod_config
()
->
argc
=
argc
;
mod_config
()
->
argv
=
new
char
*
[
argc
];
suconfig
.
argc
=
argc
;
suconfig
.
argv
=
new
char
*
[
argc
];
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
mod_config
()
->
argv
[
i
]
=
strdup
(
argv
[
i
]);
if
(
mod_config
()
->
argv
[
i
]
==
nullptr
)
{
suconfig
.
argv
[
i
]
=
strdup
(
argv
[
i
]);
if
(
suconfig
.
argv
[
i
]
==
nullptr
)
{
auto
error
=
errno
;
LOG
(
FATAL
)
<<
"failed to copy argv: "
<<
strerror
(
error
);
exit
(
EXIT_FAILURE
);
}
}
mod_config
()
->
cwd
=
getcwd
(
nullptr
,
0
);
if
(
mod_config
()
->
cwd
==
nullptr
)
{
suconfig
.
cwd
=
getcwd
(
nullptr
,
0
);
if
(
suconfig
.
cwd
==
nullptr
)
{
auto
error
=
errno
;
LOG
(
FATAL
)
<<
"failed to get current working directory: errno="
<<
error
;
exit
(
EXIT_FAILURE
);
}
auto
&
cmdcfgs
=
suconfig
.
cmdcfgs
;
while
(
1
)
{
static
int
flag
=
0
;
static
option
long_options
[]
=
{
...
...
src/shrpx_config.h
View file @
fb49182c
...
...
@@ -717,13 +717,9 @@ struct Config {
ImmutableString
conf_path
;
ImmutableString
user
;
ImmutableString
mruby_file
;
char
**
original_argv
;
char
**
argv
;
char
*
cwd
;
size_t
num_worker
;
size_t
padding
;
size_t
rlimit_nofile
;
int
argc
;
uid_t
uid
;
gid_t
gid
;
pid_t
pid
;
...
...
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