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
1a2bccd7
Commit
1a2bccd7
authored
Feb 24, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Share nghttp2_session_callbacks between objects
parent
84172753
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
51 deletions
+75
-51
src/shrpx.cc
src/shrpx.cc
+6
-0
src/shrpx_config.h
src/shrpx_config.h
+2
-0
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+40
-35
src/shrpx_http2_session.h
src/shrpx_http2_session.h
+2
-0
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+23
-16
src/shrpx_http2_upstream.h
src/shrpx_http2_upstream.h
+2
-0
No files found.
src/shrpx.cc
View file @
1a2bccd7
...
...
@@ -65,6 +65,8 @@
#include "shrpx_worker_config.h"
#include "shrpx_worker.h"
#include "shrpx_accept_handler.h"
#include "shrpx_http2_upstream.h"
#include "shrpx_http2_session.h"
#include "util.h"
#include "app_helper.h"
#include "ssl.h"
...
...
@@ -889,6 +891,10 @@ void fill_default_config() {
mod_config
()
->
padding
=
0
;
mod_config
()
->
worker_frontend_connections
=
0
;
mod_config
()
->
http2_upstream_callbacks
=
create_http2_upstream_callbacks
();
mod_config
()
->
http2_downstream_callbacks
=
create_http2_downstream_callbacks
();
nghttp2_option_new
(
&
mod_config
()
->
http2_option
);
nghttp2_option_set_no_auto_window_update
(
get_config
()
->
http2_option
,
1
);
...
...
src/shrpx_config.h
View file @
1a2bccd7
...
...
@@ -247,6 +247,8 @@ struct Config {
std
::
unique_ptr
<
char
[]
>
errorlog_file
;
FILE
*
http2_upstream_dump_request_header
;
FILE
*
http2_upstream_dump_response_header
;
nghttp2_session_callbacks
*
http2_upstream_callbacks
;
nghttp2_session_callbacks
*
http2_downstream_callbacks
;
nghttp2_option
*
http2_option
;
nghttp2_option
*
http2_client_option
;
char
**
argv
;
...
...
src/shrpx_http2_session.cc
View file @
1a2bccd7
...
...
@@ -1096,46 +1096,16 @@ int on_frame_not_send_callback(nghttp2_session *session,
}
}
// namespace
int
Http2Session
::
on_connect
()
{
nghttp2_session_callbacks
*
create_http2_downstream_callbacks
()
{
int
rv
;
state_
=
Http2Session
::
CONNECTED
;
if
(
ssl_ctx_
)
{
const
unsigned
char
*
next_proto
=
nullptr
;
unsigned
int
next_proto_len
;
SSL_get0_next_proto_negotiated
(
conn_
.
tls
.
ssl
,
&
next_proto
,
&
next_proto_len
);
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
if
(
next_proto
)
{
if
(
LOG_ENABLED
(
INFO
))
{
std
::
string
proto
(
next_proto
,
next_proto
+
next_proto_len
);
SSLOG
(
INFO
,
this
)
<<
"Negotiated next protocol: "
<<
proto
;
}
if
(
!
util
::
check_h2_is_selected
(
next_proto
,
next_proto_len
))
{
return
-
1
;
}
break
;
}
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
SSL_get0_alpn_selected
(
conn_
.
tls
.
ssl
,
&
next_proto
,
&
next_proto_len
);
#else // OPENSSL_VERSION_NUMBER < 0x10002000L
break
;
#endif // OPENSSL_VERSION_NUMBER < 0x10002000L
}
if
(
!
next_proto
)
{
return
-
1
;
}
}
nghttp2_session_callbacks
*
callbacks
;
rv
=
nghttp2_session_callbacks_new
(
&
callbacks
);
if
(
rv
!=
0
)
{
return
-
1
;
return
nullptr
;
}
auto
callbacks_deleter
=
defer
(
nghttp2_session_callbacks_del
,
callbacks
);
nghttp2_session_callbacks_set_on_stream_close_callback
(
callbacks
,
on_stream_close_callback
);
...
...
@@ -1162,8 +1132,43 @@ int Http2Session::on_connect() {
callbacks
,
http
::
select_padding_callback
);
}
rv
=
nghttp2_session_client_new2
(
&
session_
,
callbacks
,
this
,
get_config
()
->
http2_client_option
);
return
callbacks
;
}
int
Http2Session
::
on_connect
()
{
int
rv
;
state_
=
Http2Session
::
CONNECTED
;
if
(
ssl_ctx_
)
{
const
unsigned
char
*
next_proto
=
nullptr
;
unsigned
int
next_proto_len
;
SSL_get0_next_proto_negotiated
(
conn_
.
tls
.
ssl
,
&
next_proto
,
&
next_proto_len
);
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
if
(
next_proto
)
{
if
(
LOG_ENABLED
(
INFO
))
{
std
::
string
proto
(
next_proto
,
next_proto
+
next_proto_len
);
SSLOG
(
INFO
,
this
)
<<
"Negotiated next protocol: "
<<
proto
;
}
if
(
!
util
::
check_h2_is_selected
(
next_proto
,
next_proto_len
))
{
return
-
1
;
}
break
;
}
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
SSL_get0_alpn_selected
(
conn_
.
tls
.
ssl
,
&
next_proto
,
&
next_proto_len
);
#else // OPENSSL_VERSION_NUMBER < 0x10002000L
break
;
#endif // OPENSSL_VERSION_NUMBER < 0x10002000L
}
if
(
!
next_proto
)
{
return
-
1
;
}
}
rv
=
nghttp2_session_client_new2
(
&
session_
,
get_config
()
->
http2_downstream_callbacks
,
this
,
get_config
()
->
http2_client_option
);
if
(
rv
!=
0
)
{
return
-
1
;
...
...
src/shrpx_http2_session.h
View file @
1a2bccd7
...
...
@@ -194,6 +194,8 @@ private:
ReadBuf
rb_
;
};
nghttp2_session_callbacks
*
create_http2_downstream_callbacks
();
}
// namespace shrpx
#endif // SHRPX_HTTP2_SESSION_H
src/shrpx_http2_upstream.cc
View file @
1a2bccd7
...
...
@@ -605,25 +605,15 @@ void Http2Upstream::check_shutdown() {
}
}
Http2Upstream
::
Http2Upstream
(
ClientHandler
*
handler
)
:
downstream_queue_
(
get_config
()
->
http2_proxy
?
get_config
()
->
downstream_connections_per_host
:
get_config
()
->
downstream_proto
==
PROTO_HTTP
?
get_config
()
->
downstream_connections_per_frontend
:
0
,
!
get_config
()
->
http2_proxy
),
handler_
(
handler
),
session_
(
nullptr
),
data_pending_
(
nullptr
),
data_pendinglen_
(
0
),
shutdown_handled_
(
false
)
{
nghttp2_session_callbacks
*
create_http2_upstream_callbacks
()
{
int
rv
;
nghttp2_session_callbacks
*
callbacks
;
rv
=
nghttp2_session_callbacks_new
(
&
callbacks
);
assert
(
rv
==
0
);
rv
=
nghttp2_session_callbacks_new
(
&
callbacks
);
auto
callbacks_deleter
=
defer
(
nghttp2_session_callbacks_del
,
callbacks
);
if
(
rv
!=
0
)
{
return
nullptr
;
}
nghttp2_session_callbacks_set_on_stream_close_callback
(
callbacks
,
on_stream_close_callback
);
...
...
@@ -651,7 +641,24 @@ Http2Upstream::Http2Upstream(ClientHandler *handler)
callbacks
,
http
::
select_padding_callback
);
}
rv
=
nghttp2_session_server_new2
(
&
session_
,
callbacks
,
this
,
return
callbacks
;
}
Http2Upstream
::
Http2Upstream
(
ClientHandler
*
handler
)
:
downstream_queue_
(
get_config
()
->
http2_proxy
?
get_config
()
->
downstream_connections_per_host
:
get_config
()
->
downstream_proto
==
PROTO_HTTP
?
get_config
()
->
downstream_connections_per_frontend
:
0
,
!
get_config
()
->
http2_proxy
),
handler_
(
handler
),
session_
(
nullptr
),
data_pending_
(
nullptr
),
data_pendinglen_
(
0
),
shutdown_handled_
(
false
)
{
int
rv
;
rv
=
nghttp2_session_server_new2
(
&
session_
,
get_config
()
->
http2_upstream_callbacks
,
this
,
get_config
()
->
http2_option
);
assert
(
rv
==
0
);
...
...
src/shrpx_http2_upstream.h
View file @
1a2bccd7
...
...
@@ -119,6 +119,8 @@ private:
bool
shutdown_handled_
;
};
nghttp2_session_callbacks
*
create_http2_upstream_callbacks
();
}
// namespace shrpx
#endif // SHRPX_HTTP2_UPSTREAM_H
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