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
06a0f348
Commit
06a0f348
authored
Aug 12, 2015
by
Tomasz Buchert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: better handle /dev/stderr and /dev/stdout
parent
b384b76f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
22 deletions
+32
-22
src/shrpx_log.cc
src/shrpx_log.cc
+11
-20
src/util.cc
src/util.cc
+15
-1
src/util.h
src/util.h
+6
-1
No files found.
src/shrpx_log.cc
View file @
06a0f348
...
...
@@ -326,31 +326,25 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
int
reopen_log_files
()
{
int
res
=
0
;
int
new_accesslog_fd
=
-
1
;
int
new_errorlog_fd
=
-
1
;
auto
lgconf
=
log_config
();
if
(
lgconf
->
accesslog_fd
!=
-
1
)
{
close
(
lgconf
->
accesslog_fd
);
lgconf
->
accesslog_fd
=
-
1
;
}
if
(
!
get_config
()
->
accesslog_syslog
&&
get_config
()
->
accesslog_file
)
{
lgconf
->
accesslog_fd
=
util
::
reopen_log_file
(
get_config
()
->
accesslog_file
.
get
());
new_accesslog_fd
=
util
::
open_log_file
(
get_config
()
->
accesslog_file
.
get
());
if
(
lgconf
->
accesslog_fd
==
-
1
)
{
if
(
new_
accesslog_fd
==
-
1
)
{
LOG
(
ERROR
)
<<
"Failed to open accesslog file "
<<
get_config
()
->
accesslog_file
.
get
();
res
=
-
1
;
}
}
int
new_errorlog_fd
=
-
1
;
if
(
!
get_config
()
->
errorlog_syslog
&&
get_config
()
->
errorlog_file
)
{
new_errorlog_fd
=
util
::
re
open_log_file
(
get_config
()
->
errorlog_file
.
get
());
new_errorlog_fd
=
util
::
open_log_file
(
get_config
()
->
errorlog_file
.
get
());
if
(
new_errorlog_fd
==
-
1
)
{
if
(
lgconf
->
errorlog_fd
!=
-
1
)
{
...
...
@@ -365,16 +359,13 @@ int reopen_log_files() {
}
}
if
(
lgconf
->
errorlog_fd
!=
-
1
)
{
close
(
lgconf
->
errorlog_fd
);
lgconf
->
errorlog_fd
=
-
1
;
lgconf
->
errorlog_tty
=
false
;
}
util
::
close_log_file
(
lgconf
->
accesslog_fd
);
util
::
close_log_file
(
lgconf
->
errorlog_fd
);
if
(
new_errorlog_fd
!=
-
1
)
{
lgconf
->
errorlog_fd
=
new_errorlog_fd
;
lgconf
->
errorlog_tty
=
isatty
(
lgconf
->
errorlog_fd
);
}
lgconf
->
accesslog_fd
=
new_accesslog_fd
;
lgconf
->
errorlog_fd
=
new_errorlog_fd
;
lgconf
->
errorlog_tty
=
(
new_errorlog_fd
==
-
1
)
?
false
:
isatty
(
new_errorlog_fd
);
return
res
;
}
...
...
src/util.cc
View file @
06a0f348
...
...
@@ -657,7 +657,21 @@ std::string numeric_name(const struct sockaddr *sa, socklen_t salen) {
return
host
.
data
();
}
int
reopen_log_file
(
const
char
*
path
)
{
void
close_log_file
(
int
&
fd
)
{
if
(
fd
!=
STDERR_FILENO
&&
fd
!=
STDOUT_FILENO
&&
fd
!=
-
1
)
{
close
(
fd
);
}
fd
=
-
1
;
}
int
open_log_file
(
const
char
*
path
)
{
if
(
strcmp
(
path
,
"/dev/stdout"
)
==
0
)
{
return
STDOUT_FILENO
;
}
if
(
strcmp
(
path
,
"/dev/stderr"
)
==
0
)
{
return
STDERR_FILENO
;
}
#if defined(__ANDROID__) || defined(ANDROID)
int
fd
;
...
...
src/util.h
View file @
06a0f348
...
...
@@ -516,10 +516,15 @@ bool numeric_host(const char *hostname);
// failed, "unknown" is returned.
std
::
string
numeric_name
(
const
struct
sockaddr
*
sa
,
socklen_t
salen
);
// Closes |fd| which was returned by open_log_file (see below)
// and sets it to -1. In the case that |fd| points to stdout or
// stderr, or is -1, the descriptor is not closed (but still set to -1).
void
close_log_file
(
int
&
fd
);
// Opens |path| with O_APPEND enabled. If file does not exist, it is
// created first. This function returns file descriptor referring the
// opened file if it succeeds, or -1.
int
re
open_log_file
(
const
char
*
path
);
int
open_log_file
(
const
char
*
path
);
// Returns ASCII dump of |data| of length |len|. Only ASCII printable
// characters are preserved. Other characters are replaced with ".".
...
...
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