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
75c98406
Commit
75c98406
authored
Aug 02, 2012
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shrpx:: Use LOG() instead of std::cerr
parent
1dd61d59
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
21 deletions
+20
-21
examples/shrpx.cc
examples/shrpx.cc
+8
-8
examples/shrpx_config.cc
examples/shrpx_config.cc
+12
-13
No files found.
examples/shrpx.cc
View file @
75c98406
...
...
@@ -527,8 +527,8 @@ int main(int argc, char **argv)
if
(
conf_exists
(
get_config
()
->
conf_path
))
{
if
(
load_config
(
get_config
()
->
conf_path
)
==
-
1
)
{
std
::
cerr
<<
"Failed to load configuration from "
<<
get_config
()
->
conf_path
<<
std
::
endl
;
LOG
(
FATAL
)
<<
"Failed to load configuration from "
<<
get_config
()
->
conf_path
;
exit
(
EXIT_FAILURE
);
}
}
...
...
@@ -536,7 +536,7 @@ int main(int argc, char **argv)
if
((
!
get_config
()
->
private_key_file
||
!
get_config
()
->
cert_file
)
&&
argc
-
optind
<
2
)
{
print_usage
(
std
::
cerr
);
std
::
cerr
<<
"Too few arguments"
<<
std
::
endl
;
LOG
(
FATAL
)
<<
"Too few arguments"
;
exit
(
EXIT_FAILURE
);
}
if
(
argc
-
optind
>=
2
)
{
...
...
@@ -548,7 +548,7 @@ int main(int argc, char **argv)
for
(
size_t
i
=
0
,
len
=
cmdcfgs
.
size
();
i
<
len
;
++
i
)
{
if
(
parse_config
(
cmdcfgs
[
i
].
first
,
cmdcfgs
[
i
].
second
)
==
-
1
)
{
std
::
cerr
<<
"Failed to parse command-line argument."
<<
std
::
endl
;
LOG
(
FATAL
)
<<
"Failed to parse command-line argument."
;
exit
(
EXIT_FAILURE
);
}
}
...
...
@@ -576,7 +576,7 @@ int main(int argc, char **argv)
if
(
get_config
()
->
daemon
)
{
if
(
daemon
(
0
,
0
)
==
-
1
)
{
perror
(
"daemon"
);
LOG
(
FATAL
)
<<
"Failed to daemonize: "
<<
strerror
(
errno
);
exit
(
EXIT_FAILURE
);
}
}
...
...
@@ -585,15 +585,15 @@ int main(int argc, char **argv)
}
if
(
getuid
()
==
0
&&
get_config
()
->
uid
!=
0
)
{
if
(
setgid
(
get_config
()
->
gid
)
!=
0
)
{
std
::
cerr
<<
"Could not change gid: "
<<
strerror
(
errno
)
<<
std
::
endl
;
LOG
(
FATAL
)
<<
"Could not change gid: "
<<
strerror
(
errno
)
;
exit
(
EXIT_FAILURE
);
}
if
(
setuid
(
get_config
()
->
uid
)
!=
0
)
{
std
::
cerr
<<
"Could not change uid: "
<<
strerror
(
errno
)
<<
std
::
endl
;
LOG
(
FATAL
)
<<
"Could not change uid: "
<<
strerror
(
errno
)
;
exit
(
EXIT_FAILURE
);
}
if
(
setuid
(
0
)
!=
-
1
)
{
std
::
cerr
<<
"FATAL: Still have root privileges?"
<<
std
::
endl
;
LOG
(
FATAL
)
<<
"Still have root privileges?"
;
exit
(
EXIT_FAILURE
);
}
}
...
...
examples/shrpx_config.cc
View file @
75c98406
...
...
@@ -31,8 +31,8 @@
#include <cerrno>
#include <limits>
#include <fstream>
#include <iostream>
#include "shrpx_log.h"
#include "util.h"
using
namespace
spdylay
;
...
...
@@ -115,12 +115,12 @@ int split_host_port(char *host, size_t hostlen, uint16_t *port_ptr,
// host and port in |hostport| is separated by single ','.
const
char
*
p
=
strchr
(
hostport
,
','
);
if
(
!
p
)
{
std
::
cerr
<<
"Invalid host, port: "
<<
hostport
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"Invalid host, port: "
<<
hostport
;
return
-
1
;
}
size_t
len
=
p
-
hostport
;
if
(
hostlen
<
len
+
1
)
{
std
::
cerr
<<
"Hostname too long: "
<<
hostport
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"Hostname too long: "
<<
hostport
;
return
-
1
;
}
memcpy
(
host
,
hostport
,
len
);
...
...
@@ -132,7 +132,7 @@ int split_host_port(char *host, size_t hostlen, uint16_t *port_ptr,
*
port_ptr
=
d
;
return
0
;
}
else
{
std
::
cerr
<<
"Port is invalid: "
<<
p
+
1
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"Port is invalid: "
<<
p
+
1
;
return
-
1
;
}
}
...
...
@@ -170,7 +170,7 @@ int parse_config(const char *opt, const char *optarg)
mod_config
()
->
spdy_max_concurrent_streams
=
strtol
(
optarg
,
0
,
10
);
}
else
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_LOG_LEVEL
))
{
if
(
Log
::
set_severity_level_by_name
(
optarg
)
==
-
1
)
{
std
::
cerr
<<
"Invalid severity level: "
<<
optarg
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"Invalid severity level: "
<<
optarg
;
return
-
1
;
}
}
else
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_DAEMON
))
{
...
...
@@ -205,8 +205,7 @@ int parse_config(const char *opt, const char *optarg)
if
(
errno
==
0
&&
n
<
31
)
{
mod_config
()
->
spdy_upstream_window_bits
=
n
;
}
else
{
std
::
cerr
<<
"-w: specify the integer in the range [0, 30], inclusive"
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"-w: specify the integer in the range [0, 30], inclusive"
;
return
-
1
;
}
}
else
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_PID_FILE
))
{
...
...
@@ -214,8 +213,8 @@ int parse_config(const char *opt, const char *optarg)
}
else
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_USER
))
{
passwd
*
pwd
=
getpwnam
(
optarg
);
if
(
pwd
==
0
)
{
std
::
cerr
<<
"--user: failed to get uid from "
<<
optarg
<<
": "
<<
strerror
(
errno
)
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"--user: failed to get uid from "
<<
optarg
<<
": "
<<
strerror
(
errno
)
;
return
-
1
;
}
mod_config
()
->
uid
=
pwd
->
pw_uid
;
...
...
@@ -225,9 +224,9 @@ int parse_config(const char *opt, const char *optarg)
}
else
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_CERTIFICATE_FILE
))
{
set_config_str
(
&
mod_config
()
->
cert_file
,
optarg
);
}
else
if
(
util
::
strieq
(
opt
,
"conf"
))
{
std
::
cerr
<<
"conf is ignored"
<<
std
::
endl
;
LOG
(
WARNING
)
<<
"conf is ignored"
;
}
else
{
std
::
cerr
<<
"Unknown option: "
<<
opt
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"Unknown option: "
<<
opt
;
return
-
1
;
}
return
0
;
...
...
@@ -237,7 +236,7 @@ int load_config(const char *filename)
{
std
::
ifstream
in
(
filename
,
std
::
ios
::
binary
);
if
(
!
in
)
{
std
::
cerr
<<
"Could not open config file "
<<
filename
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"Could not open config file "
<<
filename
;
return
-
1
;
}
std
::
string
line
;
...
...
@@ -251,7 +250,7 @@ int load_config(const char *filename)
size_t
size
=
line
.
size
();
for
(
i
=
0
;
i
<
size
&&
line
[
i
]
!=
'='
;
++
i
);
if
(
i
==
size
)
{
std
::
cerr
<<
"Bad configuration format at line "
<<
linenum
<<
std
::
endl
;
LOG
(
ERROR
)
<<
"Bad configuration format at line "
<<
linenum
;
return
-
1
;
}
line
[
i
]
=
'\0'
;
...
...
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