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
959d378f
Commit
959d378f
authored
Jan 17, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Optimize accesslog write
parent
506de554
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
29 deletions
+46
-29
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+25
-24
src/shrpx_log.cc
src/shrpx_log.cc
+8
-0
src/shrpx_log.h
src/shrpx_log.h
+8
-5
src/template.h
src/template.h
+5
-0
No files found.
src/shrpx_client_handler.cc
View file @
959d378f
...
...
@@ -835,25 +835,27 @@ void ClientHandler::write_accesslog(Downstream *downstream) {
upstream_accesslog
(
get_config
()
->
accesslog_format
,
LogSpec
{
downstream
,
ipaddr_
.
c_str
()
,
http2
::
to_method_string
(
req
.
method
),
downstream
,
ipaddr_
,
http2
::
to_method_string
(
req
.
method
),
req
.
method
==
HTTP_CONNECT
?
req
.
authority
.
c_str
()
?
req
.
authority
:
(
get_config
()
->
http2_proxy
||
get_config
()
->
client_proxy
)
?
construct_absolute_request_uri
(
req
).
c_str
()
:
req
.
path
.
empty
()
?
req
.
method
==
HTTP_OPTIONS
?
"*"
:
"-"
:
req
.
path
.
c_str
(),
?
construct_absolute_request_uri
(
req
)
:
req
.
path
.
empty
()
?
req
.
method
==
HTTP_OPTIONS
?
StringAdaptor
::
from_lit
(
"*"
)
:
StringAdaptor
::
from_lit
(
"-"
)
:
req
.
path
,
alpn_
.
c_str
(),
nghttp2
::
ssl
::
get_tls_session_info
(
&
tls_info
,
conn_
.
tls
.
ssl
),
alpn_
,
nghttp2
::
ssl
::
get_tls_session_info
(
&
tls_info
,
conn_
.
tls
.
ssl
),
std
::
chrono
::
system_clock
::
now
(),
// time_now
downstream
->
get_request_start_time
(),
// request_start_time
std
::
chrono
::
high_resolution_clock
::
now
(),
// request_end_time
req
.
http_major
,
req
.
http_minor
,
resp
.
http_status
,
downstream
->
response_sent_body_length
,
port_
.
c_str
()
,
get_config
()
->
p
ort
,
get_config
()
->
p
id
,
downstream
->
response_sent_body_length
,
port_
,
get_config
()
->
port
,
get_config
()
->
pid
,
});
}
...
...
@@ -863,21 +865,20 @@ void ClientHandler::write_accesslog(int major, int minor, unsigned int status,
auto
highres_now
=
std
::
chrono
::
high_resolution_clock
::
now
();
nghttp2
::
ssl
::
TLSSessionInfo
tls_info
;
upstream_accesslog
(
get_config
()
->
accesslog_format
,
LogSpec
{
nullptr
,
ipaddr_
.
c_str
(),
"-"
,
// method
"-"
,
// path,
alpn_
.
c_str
(),
nghttp2
::
ssl
::
get_tls_session_info
(
&
tls_info
,
conn_
.
tls
.
ssl
),
time_now
,
highres_now
,
// request_start_time TODO is
// there a better value?
highres_now
,
// request_end_time
major
,
minor
,
// major, minor
status
,
body_bytes_sent
,
port_
.
c_str
(),
get_config
()
->
port
,
get_config
()
->
pid
,
});
upstream_accesslog
(
get_config
()
->
accesslog_format
,
LogSpec
{
nullptr
,
ipaddr_
,
StringAdaptor
::
from_lit
(
"-"
),
// method
StringAdaptor
::
from_lit
(
"-"
),
// path,
alpn_
,
nghttp2
::
ssl
::
get_tls_session_info
(
&
tls_info
,
conn_
.
tls
.
ssl
),
time_now
,
highres_now
,
// request_start_time TODO is
// there a better value?
highres_now
,
// request_end_time
major
,
minor
,
// major, minor
status
,
body_bytes_sent
,
port_
,
get_config
()
->
port
,
get_config
()
->
pid
,
});
}
ClientHandler
::
ReadBuf
*
ClientHandler
::
get_rb
()
{
return
&
rb_
;
}
...
...
src/shrpx_log.cc
View file @
959d378f
...
...
@@ -182,6 +182,14 @@ std::pair<OutputIterator, size_t> copy(const std::string &src, size_t avail,
}
}
// namespace
namespace
{
template
<
typename
OutputIterator
>
std
::
pair
<
OutputIterator
,
size_t
>
copy
(
const
StringAdaptor
&
src
,
size_t
avail
,
OutputIterator
oitr
)
{
return
copy
(
src
.
c_str
(),
src
.
size
(),
avail
,
oitr
);
}
}
// namespace
namespace
{
template
<
size_t
N
,
typename
OutputIterator
>
std
::
pair
<
OutputIterator
,
size_t
>
copy_l
(
const
char
(
&
src
)[
N
],
size_t
avail
,
...
...
src/shrpx_log.h
View file @
959d378f
...
...
@@ -36,6 +36,9 @@
#include "shrpx_log_config.h"
#include "ssl.h"
#include "template.h"
using
namespace
nghttp2
;
#define ENABLE_LOG 1
...
...
@@ -139,10 +142,10 @@ struct LogFragment {
struct
LogSpec
{
Downstream
*
downstream
;
const
char
*
remote_addr
;
const
char
*
method
;
const
char
*
path
;
const
char
*
alpn
;
StringAdaptor
remote_addr
;
StringAdaptor
method
;
StringAdaptor
path
;
StringAdaptor
alpn
;
const
nghttp2
::
ssl
::
TLSSessionInfo
*
tls_info
;
std
::
chrono
::
system_clock
::
time_point
time_now
;
std
::
chrono
::
high_resolution_clock
::
time_point
request_start_time
;
...
...
@@ -150,7 +153,7 @@ struct LogSpec {
int
major
,
minor
;
unsigned
int
status
;
int64_t
body_bytes_sent
;
const
char
*
remote_port
;
StringAdaptor
remote_port
;
uint16_t
server_port
;
pid_t
pid
;
};
...
...
src/template.h
View file @
959d378f
...
...
@@ -254,6 +254,11 @@ struct StringAdaptor {
StringAdaptor
(
const
T
&
s
)
:
base
(
s
.
c_str
()),
len
(
s
.
size
())
{}
StringAdaptor
(
const
char
*
s
)
:
base
(
s
),
len
(
strlen
(
s
))
{}
StringAdaptor
(
const
char
*
s
,
size_t
n
)
:
base
(
s
),
len
(
n
)
{}
template
<
size_t
N
>
static
StringAdaptor
from_lit
(
const
char
(
&
s
)[
N
])
{
return
StringAdaptor
(
s
,
N
-
1
);
}
const
char
*
c_str
()
const
{
return
base
;
}
size_t
size
()
const
{
return
len
;
}
...
...
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