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
d044c585
Commit
d044c585
authored
Sep 04, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Detect mruby presence and guard mruby related code with ifdef
parent
200217d8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
7 deletions
+75
-7
configure.ac
configure.ac
+30
-0
src/Makefile.am
src/Makefile.am
+13
-7
src/shrpx_connection_handler.cc
src/shrpx_connection_handler.cc
+4
-0
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+6
-0
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+6
-0
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+6
-0
src/shrpx_worker.cc
src/shrpx_worker.cc
+4
-0
src/shrpx_worker.h
src/shrpx_worker.h
+6
-0
No files found.
configure.ac
View file @
d044c585
...
...
@@ -119,6 +119,11 @@ AC_ARG_WITH([spdylay],
[Use spdylay [default=check]])],
[request_spdylay=$withval], [request_spdylay=check])
AC_ARG_WITH([mruby],
[AS_HELP_STRING([--with-mruby],
[Use mruby [default=check]])],
[request_mruby=$withval], [request_mruby=check])
AC_ARG_WITH([cython],
[AS_HELP_STRING([--with-cython=PATH],
[Use cython in given PATH])],
...
...
@@ -370,6 +375,30 @@ fi
AM_CONDITIONAL([HAVE_SPDYLAY], [ test "x${have_spdylay}" = "xyes" ])
# mruby (for src/nghttpx)
LIBS_OLD=$LIBS
have_mruby=no
if test "x${request_mruby}" != "xno"; then
AC_CHECK_LIB([mruby], [mrb_open], [have_mruby=yes], [have_mruby=no])
if test "x${have_mruby}" = "xyes"; then
AC_CHECK_HEADER([mruby.h], [have_mruby=yes], [have_mruby=no])
if test "x${have_mruby}" = "xyes"; then
LIBMRUBY_LIBS=-lmruby
LIBMRUBY_CFLAGS=
AC_SUBST([LIBMRUBY_LIBS])
AC_SUBST([LIBMRUBY_CFLAGS])
fi
fi
fi
LIBS=$LIBS_OLD
if test "x${request_mruby}" = "xyes" &&
test "x${have_mruby}" != "xyes"; then
AC_MSG_ERROR([mruby was requested (--with-mruby) but not found])
fi
AM_CONDITIONAL([HAVE_MRUBY], [test "x${have_mruby}" = "xyes"])
# Check Boost Asio library
have_asio_lib=no
...
...
@@ -717,6 +746,7 @@ AC_MSG_NOTICE([summary of build options:
Libev: ${have_libev}
Libevent(SSL): ${have_libevent_openssl}
Spdylay: ${have_spdylay}
MRuby: ${have_mruby}
Jansson: ${have_jansson}
Jemalloc: ${have_jemalloc}
Zlib: ${have_zlib}
...
...
src/Makefile.am
View file @
d044c585
...
...
@@ -124,21 +124,26 @@ NGHTTPX_SRCS = \
shrpx_memcached_connection.cc shrpx_memcached_connection.h
\
shrpx_memcached_request.h
\
shrpx_memcached_result.h
\
shrpx_mruby.cc shrpx_mruby.h
\
shrpx_mruby_module.cc shrpx_mruby_module.h
\
shrpx_mruby_module_request.cc shrpx_mruby_module_request.h
\
shrpx_mruby_module_response.cc shrpx_mruby_module_response.h
\
buffer.h memchunk.h template.h
if
HAVE_SPDYLAY
NGHTTPX_SRCS
+=
shrpx_spdy_upstream.cc shrpx_spdy_upstream.h
endif
# HAVE_SPDYLAY
if
HAVE_MRUBY
NGHTTPX_SRCS
+=
\
shrpx_mruby.cc shrpx_mruby.h
\
shrpx_mruby_module.cc shrpx_mruby_module.h
\
shrpx_mruby_module_request.cc shrpx_mruby_module_request.h
\
shrpx_mruby_module_response.cc shrpx_mruby_module_response.h
endif
# HAVE_MRUBY
noinst_LIBRARIES
=
libnghttpx.a
libnghttpx_a_SOURCES
=
${NGHTTPX_SRCS}
nghttpx_SOURCES
=
shrpx.cc shrpx.h
nghttpx_LDADD
=
libnghttpx.a
${LDADD}
-lmruby
nghttpx_CPPFLAGS
=
${AM_CPPFLAGS}
@LIBMRUBY_CFLAGS@
nghttpx_LDADD
=
libnghttpx.a
${LDADD}
@LIBMRUBY_LIBS@
if
HAVE_CUNIT
check_PROGRAMS
+=
nghttpx-unittest
...
...
@@ -152,9 +157,10 @@ nghttpx_unittest_SOURCES = shrpx-unittest.cc \
nghttp2_gzip.c nghttp2_gzip.h
\
buffer_test.cc buffer_test.h
\
memchunk_test.cc memchunk_test.h
nghttpx_unittest_CPPFLAGS
=
${AM_CPPFLAGS}
\
nghttpx_unittest_CPPFLAGS
=
${AM_CPPFLAGS}
@LIBMRUBY_CFLAGS@
\
-DNGHTTP2_TESTS_DIR
=
\"
$(top_srcdir)
/tests
\"
nghttpx_unittest_LDADD
=
libnghttpx.a
${LDADD}
-lmruby
@CUNIT_LIBS@ @TESTLDADD@
nghttpx_unittest_LDADD
=
libnghttpx.a
${LDADD}
\
@LIBMRUBY_LIBS@ @CUNIT_LIBS@ @TESTLDADD@
TESTS
+=
nghttpx-unittest
endif
# HAVE_CUNIT
...
...
src/shrpx_connection_handler.cc
View file @
d044c585
...
...
@@ -160,9 +160,11 @@ int ConnectionHandler::create_single_worker() {
single_worker_
=
make_unique
<
Worker
>
(
loop_
,
sv_ssl_ctx
,
cl_ssl_ctx
,
cert_tree
,
ticket_keys_
);
#ifdef HAVE_MRUBY
if
(
single_worker_
->
create_mruby_context
()
!=
0
)
{
return
-
1
;
}
#endif // HAVE_MRUBY
return
0
;
}
...
...
@@ -184,9 +186,11 @@ int ConnectionHandler::create_worker_thread(size_t num) {
auto
worker
=
make_unique
<
Worker
>
(
loop
,
sv_ssl_ctx
,
cl_ssl_ctx
,
cert_tree
,
ticket_keys_
);
#ifdef HAVE_MRUBY
if
(
worker
->
create_mruby_context
()
!=
0
)
{
return
-
1
;
}
#endif // HAVE_MRUBY
workers_
.
push_back
(
std
::
move
(
worker
));
...
...
src/shrpx_http2_upstream.cc
View file @
d044c585
...
...
@@ -37,7 +37,9 @@
#include "shrpx_http.h"
#include "shrpx_worker.h"
#include "shrpx_http2_session.h"
#ifdef HAVE_MRUBY
#include "shrpx_mruby.h"
#endif // HAVE_MRUBY
#include "http2.h"
#include "util.h"
#include "base64.h"
...
...
@@ -318,6 +320,7 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
downstream
->
set_request_state
(
Downstream
::
HEADER_COMPLETE
);
#ifdef HAVE_MRUBY
auto
upstream
=
downstream
->
get_upstream
();
auto
handler
=
upstream
->
get_client_handler
();
auto
worker
=
handler
->
get_worker
();
...
...
@@ -329,6 +332,7 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
}
return
0
;
}
#endif // HAVE_MRUBY
if
(
frame
->
hd
.
flags
&
NGHTTP2_FLAG_END_STREAM
)
{
downstream
->
disable_upstream_rtimer
();
...
...
@@ -1271,6 +1275,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
downstream
->
get_request_http2_scheme
());
}
#ifdef HAVE_MRUBY
if
(
!
downstream
->
get_non_final_response
())
{
auto
worker
=
handler_
->
get_worker
();
auto
mruby_ctx
=
worker
->
get_mruby_context
();
...
...
@@ -1286,6 +1291,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
return
-
1
;
}
}
#endif // HAVE_MRUBY
size_t
nheader
=
downstream
->
get_response_headers
().
size
();
auto
nva
=
std
::
vector
<
nghttp2_nv
>
();
...
...
src/shrpx_https_upstream.cc
View file @
d044c585
...
...
@@ -37,7 +37,9 @@
#include "shrpx_log_config.h"
#include "shrpx_worker.h"
#include "shrpx_http2_session.h"
#ifdef HAVE_MRUBY
#include "shrpx_mruby.h"
#endif // HAVE_MRUBY
#include "http2.h"
#include "util.h"
#include "template.h"
...
...
@@ -328,6 +330,7 @@ int htp_hdrs_completecb(http_parser *htp) {
downstream
->
set_request_state
(
Downstream
::
HEADER_COMPLETE
);
#ifdef HAVE_MRUBY
auto
handler
=
upstream
->
get_client_handler
();
auto
worker
=
handler
->
get_worker
();
auto
mruby_ctx
=
worker
->
get_mruby_context
();
...
...
@@ -336,6 +339,7 @@ int htp_hdrs_completecb(http_parser *htp) {
downstream
->
set_response_http_status
(
500
);
return
-
1
;
}
#endif // HAVE_MRUBY
// mruby hook may change method value
...
...
@@ -888,6 +892,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
}
}
#ifdef HAVE_MRUBY
if
(
!
downstream
->
get_non_final_response
())
{
auto
worker
=
handler_
->
get_worker
();
auto
mruby_ctx
=
worker
->
get_mruby_context
();
...
...
@@ -901,6 +906,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
return
-
1
;
}
}
#endif // HAVE_MRUBY
auto
connect_method
=
downstream
->
get_request_method
()
==
HTTP_CONNECT
;
...
...
src/shrpx_spdy_upstream.cc
View file @
d044c585
...
...
@@ -36,7 +36,9 @@
#include "shrpx_downstream_connection.h"
#include "shrpx_config.h"
#include "shrpx_http.h"
#ifdef HAVE_MRUBY
#include "shrpx_mruby.h"
#endif // HAVE_MRUBY
#include "shrpx_worker.h"
#include "shrpx_http2_session.h"
#include "http2.h"
...
...
@@ -243,6 +245,7 @@ void on_ctrl_recv_callback(spdylay_session *session, spdylay_frame_type type,
downstream
->
set_request_state
(
Downstream
::
HEADER_COMPLETE
);
#ifdef HAVE_MRUBY
auto
handler
=
upstream
->
get_client_handler
();
auto
worker
=
handler
->
get_worker
();
auto
mruby_ctx
=
worker
->
get_mruby_context
();
...
...
@@ -254,6 +257,7 @@ void on_ctrl_recv_callback(spdylay_session *session, spdylay_frame_type type,
}
return
;
}
#endif // HAVE_MRUBY
if
(
frame
->
syn_stream
.
hd
.
flags
&
SPDYLAY_CTRL_FLAG_FIN
)
{
if
(
!
downstream
->
validate_request_bodylen
())
{
...
...
@@ -930,6 +934,7 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream) {
return
0
;
}
#ifdef HAVE_MRUBY
auto
worker
=
handler_
->
get_worker
();
auto
mruby_ctx
=
worker
->
get_mruby_context
();
...
...
@@ -943,6 +948,7 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream) {
if
(
downstream
->
get_response_state
()
==
Downstream
::
MSG_COMPLETE
)
{
return
-
1
;
}
#endif // HAVE_MRUBY
if
(
LOG_ENABLED
(
INFO
))
{
DLOG
(
INFO
,
downstream
)
<<
"HTTP response header completed"
;
...
...
src/shrpx_worker.cc
View file @
d044c585
...
...
@@ -37,7 +37,9 @@
#include "shrpx_log_config.h"
#include "shrpx_connect_blocker.h"
#include "shrpx_memcached_dispatcher.h"
#ifdef HAVE_MRUBY
#include "shrpx_mruby.h"
#endif // HAVE_MRUBY
#include "util.h"
#include "template.h"
...
...
@@ -266,6 +268,7 @@ MemcachedDispatcher *Worker::get_session_cache_memcached_dispatcher() {
return
session_cache_memcached_dispatcher_
.
get
();
}
#ifdef HAVE_MRUBY
int
Worker
::
create_mruby_context
()
{
mruby_ctx_
=
mruby
::
create_mruby_context
();
if
(
!
mruby_ctx_
)
{
...
...
@@ -278,5 +281,6 @@ int Worker::create_mruby_context() {
mruby
::
MRubyContext
*
Worker
::
get_mruby_context
()
const
{
return
mruby_ctx_
.
get
();
}
#endif // HAVE_MRUBY
}
// namespace shrpx
src/shrpx_worker.h
View file @
d044c585
...
...
@@ -51,11 +51,13 @@ class Http2Session;
class
ConnectBlocker
;
class
MemcachedDispatcher
;
#ifdef HAVE_MRUBY
namespace
mruby
{
class
MRubyContext
;
}
// namespace mruby
#endif // HAVE_MRUBY
namespace
ssl
{
class
CertLookupTree
;
...
...
@@ -130,9 +132,11 @@ public:
MemcachedDispatcher
*
get_session_cache_memcached_dispatcher
();
#ifdef HAVE_MRUBY
int
create_mruby_context
();
mruby
::
MRubyContext
*
get_mruby_context
()
const
;
#endif // HAVE_MRUBY
private:
#ifndef NOTHREADS
...
...
@@ -147,7 +151,9 @@ private:
WorkerStat
worker_stat_
;
std
::
vector
<
DownstreamGroup
>
dgrps_
;
std
::
unique_ptr
<
MemcachedDispatcher
>
session_cache_memcached_dispatcher_
;
#ifdef HAVE_MRUBY
std
::
unique_ptr
<
mruby
::
MRubyContext
>
mruby_ctx_
;
#endif // HAVE_MRUBY
struct
ev_loop
*
loop_
;
// Following fields are shared across threads if
...
...
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