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
fb62a5ed
Commit
fb62a5ed
authored
Aug 19, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Use pointer for worker_config
parent
34512197
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
35 deletions
+40
-35
src/shrpx.cc
src/shrpx.cc
+7
-7
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+1
-1
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+1
-1
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+1
-1
src/shrpx_listen_handler.cc
src/shrpx_listen_handler.cc
+1
-1
src/shrpx_log.cc
src/shrpx_log.cc
+23
-18
src/shrpx_log.h
src/shrpx_log.h
+2
-2
src/shrpx_thread_event_receiver.cc
src/shrpx_thread_event_receiver.cc
+2
-2
src/shrpx_worker_config.cc
src/shrpx_worker_config.cc
+1
-1
src/shrpx_worker_config.h
src/shrpx_worker_config.h
+1
-1
No files found.
src/shrpx.cc
View file @
fb62a5ed
...
...
@@ -335,7 +335,7 @@ void reopen_log_signal_cb(evutil_socket_t sig, short events, void *arg)
auto
listener_handler
=
static_cast
<
ListenHandler
*>
(
arg
);
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Reopening log files: worker_info("
<<
&
worker_config
<<
")"
;
LOG
(
INFO
)
<<
"Reopening log files: worker_info("
<<
worker_config
<<
")"
;
}
(
void
)
reopen_log_files
();
...
...
@@ -456,7 +456,7 @@ void graceful_shutdown_signal_cb(evutil_socket_t sig, short events, void *arg)
listener_handler
->
accept_pending_connection
();
worker_config
.
graceful_shutdown
=
true
;
worker_config
->
graceful_shutdown
=
true
;
listener_handler
->
graceful_shutdown_worker
();
}
...
...
@@ -495,7 +495,7 @@ void refresh_cb(evutil_socket_t sig, short events, void *arg)
// In multi threaded mode (get_config()->num_worker > 1), we have to
// wait for event notification to workers to finish.
if
(
get_config
()
->
num_worker
==
1
&&
worker_config
.
graceful_shutdown
&&
worker_config
->
graceful_shutdown
&&
(
!
worker_stat
||
worker_stat
->
num_connections
==
0
))
{
event_base_loopbreak
(
listener_handler
->
get_evbase
());
}
...
...
@@ -1642,15 +1642,15 @@ int main(int argc, char **argv)
}
if
(
get_config
()
->
uid
!=
0
)
{
if
(
worker_config
.
accesslog_fd
!=
-
1
&&
fchown
(
worker_config
.
accesslog_fd
,
if
(
worker_config
->
accesslog_fd
!=
-
1
&&
fchown
(
worker_config
->
accesslog_fd
,
get_config
()
->
uid
,
get_config
()
->
gid
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARNING
)
<<
"Changing owner of access log file failed: "
<<
strerror
(
error
);
}
if
(
worker_config
.
errorlog_fd
!=
-
1
&&
fchown
(
worker_config
.
errorlog_fd
,
if
(
worker_config
->
errorlog_fd
!=
-
1
&&
fchown
(
worker_config
->
errorlog_fd
,
get_config
()
->
uid
,
get_config
()
->
gid
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARNING
)
<<
"Changing owner of error log file failed: "
...
...
src/shrpx_client_handler.cc
View file @
fb62a5ed
...
...
@@ -274,7 +274,7 @@ ClientHandler::~ClientHandler()
// TODO If backend is http/2, and it is in CONNECTED state, signal
// it and make it loopbreak when output is zero.
if
(
worker_config
.
graceful_shutdown
&&
worker_stat_
->
num_connections
==
0
)
{
if
(
worker_config
->
graceful_shutdown
&&
worker_stat_
->
num_connections
==
0
)
{
event_base_loopbreak
(
get_evbase
());
}
...
...
src/shrpx_http_downstream_connection.cc
View file @
fb62a5ed
...
...
@@ -255,7 +255,7 @@ int HttpDownstreamConnection::push_request_headers()
if
(
LOG_ENABLED
(
INFO
))
{
const
char
*
hdrp
;
std
::
string
nhdrs
;
if
(
worker_config
.
errorlog_tty
)
{
if
(
worker_config
->
errorlog_tty
)
{
nhdrs
=
http
::
colorizeHeaders
(
hdrs
.
c_str
());
hdrp
=
nhdrs
.
c_str
();
}
else
{
...
...
src/shrpx_https_upstream.cc
View file @
fb62a5ed
...
...
@@ -940,7 +940,7 @@ void HttpsUpstream::log_response_headers(const std::string& hdrs) const
{
const
char
*
hdrp
;
std
::
string
nhdrs
;
if
(
worker_config
.
errorlog_tty
)
{
if
(
worker_config
->
errorlog_tty
)
{
nhdrs
=
http
::
colorizeHeaders
(
hdrs
.
c_str
());
hdrp
=
nhdrs
.
c_str
();
}
else
{
...
...
src/shrpx_listen_handler.cc
View file @
fb62a5ed
...
...
@@ -82,7 +82,7 @@ void worker_writecb(bufferevent *bev, void *ptr)
auto
listener_handler
=
static_cast
<
ListenHandler
*>
(
ptr
);
auto
output
=
bufferevent_get_output
(
bev
);
if
(
!
worker_config
.
graceful_shutdown
||
if
(
!
worker_config
->
graceful_shutdown
||
evbuffer_get_length
(
output
)
!=
0
)
{
return
;
}
...
...
src/shrpx_log.cc
View file @
fb62a5ed
...
...
@@ -102,8 +102,10 @@ Log::~Log()
{
int
rv
;
auto
wconf
=
worker_config
;
if
(
!
log_enabled
(
severity_
)
||
(
w
orker_config
.
errorlog_fd
==
-
1
&&
!
get_config
()
->
errorlog_syslog
))
{
(
w
conf
->
errorlog_fd
==
-
1
&&
!
get_config
()
->
errorlog_syslog
))
{
return
;
}
...
...
@@ -116,7 +118,7 @@ Log::~Log()
}
char
buf
[
4096
];
auto
tty
=
w
orker_config
.
errorlog_tty
;
auto
tty
=
w
conf
->
errorlog_tty
;
auto
cached_time
=
get_config
()
->
cached_time
;
...
...
@@ -138,13 +140,15 @@ Log::~Log()
auto
nwrite
=
std
::
min
(
static_cast
<
size_t
>
(
rv
),
sizeof
(
buf
)
-
1
);
while
(
write
(
w
orker_config
.
errorlog_fd
,
buf
,
nwrite
)
==
-
1
&&
errno
==
EINTR
);
while
(
write
(
w
conf
->
errorlog_fd
,
buf
,
nwrite
)
==
-
1
&&
errno
==
EINTR
);
}
void
upstream_accesslog
(
const
std
::
string
&
client_ip
,
unsigned
int
status_code
,
Downstream
*
downstream
)
{
if
(
worker_config
.
accesslog_fd
==
-
1
&&
!
get_config
()
->
accesslog_syslog
)
{
auto
wconf
=
worker_config
;
if
(
wconf
->
accesslog_fd
==
-
1
&&
!
get_config
()
->
accesslog_syslog
)
{
return
;
}
...
...
@@ -209,25 +213,26 @@ void upstream_accesslog(const std::string& client_ip, unsigned int status_code,
return
;
}
while
(
write
(
worker_config
.
accesslog_fd
,
buf
,
nwrite
)
==
-
1
&&
errno
==
EINTR
);
while
(
write
(
wconf
->
accesslog_fd
,
buf
,
nwrite
)
==
-
1
&&
errno
==
EINTR
);
}
int
reopen_log_files
()
{
int
res
=
0
;
if
(
worker_config
.
accesslog_fd
!=
-
1
)
{
close
(
worker_config
.
accesslog_fd
);
worker_config
.
accesslog_fd
=
-
1
;
auto
wconf
=
worker_config
;
if
(
wconf
->
accesslog_fd
!=
-
1
)
{
close
(
wconf
->
accesslog_fd
);
wconf
->
accesslog_fd
=
-
1
;
}
if
(
!
get_config
()
->
accesslog_syslog
&&
get_config
()
->
accesslog_file
)
{
w
orker_config
.
accesslog_fd
=
w
conf
->
accesslog_fd
=
util
::
reopen_log_file
(
get_config
()
->
accesslog_file
.
get
());
if
(
w
orker_config
.
accesslog_fd
==
-
1
)
{
if
(
w
conf
->
accesslog_fd
==
-
1
)
{
LOG
(
ERROR
)
<<
"Failed to open accesslog file "
<<
get_config
()
->
accesslog_file
.
get
();
res
=
-
1
;
...
...
@@ -241,7 +246,7 @@ int reopen_log_files()
new_errorlog_fd
=
util
::
reopen_log_file
(
get_config
()
->
errorlog_file
.
get
());
if
(
new_errorlog_fd
==
-
1
)
{
if
(
w
orker_config
.
errorlog_fd
!=
-
1
)
{
if
(
w
conf
->
errorlog_fd
!=
-
1
)
{
LOG
(
ERROR
)
<<
"Failed to open errorlog file "
<<
get_config
()
->
errorlog_file
.
get
();
}
else
{
...
...
@@ -254,15 +259,15 @@ int reopen_log_files()
}
}
if
(
w
orker_config
.
errorlog_fd
!=
-
1
)
{
close
(
w
orker_config
.
errorlog_fd
);
w
orker_config
.
errorlog_fd
=
-
1
;
w
orker_config
.
errorlog_tty
=
false
;
if
(
w
conf
->
errorlog_fd
!=
-
1
)
{
close
(
w
conf
->
errorlog_fd
);
w
conf
->
errorlog_fd
=
-
1
;
w
conf
->
errorlog_tty
=
false
;
}
if
(
new_errorlog_fd
!=
-
1
)
{
w
orker_config
.
errorlog_fd
=
new_errorlog_fd
;
w
orker_config
.
errorlog_tty
=
isatty
(
worker_config
.
errorlog_fd
);
w
conf
->
errorlog_fd
=
new_errorlog_fd
;
w
conf
->
errorlog_tty
=
isatty
(
wconf
->
errorlog_fd
);
}
return
res
;
...
...
src/shrpx_log.h
View file @
fb62a5ed
...
...
@@ -97,8 +97,8 @@ private:
static
int
severity_thres_
;
};
#define TTY_HTTP_HD (worker_config
.
errorlog_tty ? "\033[1;34m" : "")
#define TTY_RST (worker_config
.
errorlog_tty ? "\033[0m" : "")
#define TTY_HTTP_HD (worker_config
->
errorlog_tty ? "\033[1;34m" : "")
#define TTY_RST (worker_config
->
errorlog_tty ? "\033[0m" : "")
void
upstream_accesslog
(
const
std
::
string
&
client_ip
,
unsigned
int
status_code
,
Downstream
*
downstream
);
...
...
src/shrpx_thread_event_receiver.cc
View file @
fb62a5ed
...
...
@@ -73,7 +73,7 @@ void ThreadEventReceiver::on_read(bufferevent *bev)
if
(
wev
.
type
==
REOPEN_LOG
)
{
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Reopening log files: worker_info("
<<
&
worker_config
<<
")"
;
<<
worker_config
<<
")"
;
}
reopen_log_files
();
...
...
@@ -86,7 +86,7 @@ void ThreadEventReceiver::on_read(bufferevent *bev)
LOG
(
INFO
)
<<
"Graceful shutdown commencing"
;
}
worker_config
.
graceful_shutdown
=
true
;
worker_config
->
graceful_shutdown
=
true
;
if
(
worker_stat_
->
num_connections
==
0
)
{
event_base_loopbreak
(
evbase_
);
...
...
src/shrpx_worker_config.cc
View file @
fb62a5ed
...
...
@@ -36,7 +36,7 @@ WorkerConfig::WorkerConfig()
#ifndef NOTHREADS
thread_local
#endif // NOTHREADS
WorkerConfig
worker_config
;
WorkerConfig
*
worker_config
=
new
WorkerConfig
()
;
}
// namespace shrpx
src/shrpx_worker_config.h
View file @
fb62a5ed
...
...
@@ -44,7 +44,7 @@ extern
#ifndef NOTHREADS
thread_local
#endif // NOTHREADS
WorkerConfig
worker_config
;
WorkerConfig
*
worker_config
;
}
// 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