Commit Graph

758 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa 8fffa05513 src: Fix possible heap-use-after free for OpenSSL global locking
This is simply programming error, but it is interesting that using
libstdc++ does not reveal this error.  With clang++-libc++, we got
std::system_error: mutex lock faild: Invalid argument.  This is
because we did not give a name to lock object, so it is immediately
destructed.  I think this will fix the reported crash on Mac OSX.
2014-10-14 21:47:07 +09:00
Tatsuhiro Tsujikawa 0d4120ce2c nghttpx: Apply same fix from a225bb2 to spdy upstream 2014-10-13 21:13:45 +09:00
Tatsuhiro Tsujikawa 20de432725 nghttpx: Pool http downstream connection per thread 2014-10-13 21:09:00 +09:00
Tatsuhiro Tsujikawa 225b90eefd Use switch-case instead of if 2014-10-10 22:52:47 +09:00
Tatsuhiro Tsujikawa 3931a0b04d Fix bugs found by coverity scan 2014-10-10 22:50:35 +09:00
Tatsuhiro Tsujikawa bcbb2e8649 src: Use fcntl and FD_CLOEXEC if O_CLOEXEC is undefined
We may run into race condition if execve is called at the same time
when fcntl is called.  But we just does this for now to compile
nghttp2 applications under older kernel.
2014-10-08 23:44:38 +09:00
Tatsuhiro Tsujikawa a225bb29df nghttpx: Fix request is sent to backend prematurely with http2 upstream 2014-10-07 00:31:35 +09:00
Tatsuhiro Tsujikawa 7a09feebc3 h2load: Don't use std::future with --disable-threads
Now we don't use std::future with --disable-threads, checking
std::future in configure.ac was removed and building h2load is always
enabled.
2014-10-05 14:25:15 +09:00
Svante Signell df875db989 Avoid PATH_MAX by using getcwd(nullptr, 0) as supported by modern glibc-based OSes. 2014-10-03 21:58:15 +09:00
Tatsuhiro Tsujikawa 4f0d03b4b9 libnghttp2_asio: Move common types and functions to nghttp2::asio_http2 ns 2014-09-28 16:54:00 +09:00
Tatsuhiro Tsujikawa 88d7abcc23 libnghttp2_asio: Add request::run_task to execute task in separate thread 2014-09-28 16:25:45 +09:00
Tatsuhiro Tsujikawa e20d2ba9c1 nghttpx: Don't send x-forwarded-proto if -s or -p is used 2014-09-25 00:41:38 +09:00
Tatsuhiro Tsujikawa c1be28684a libnghttp2_asio: Add request::closed() to indicate that stream has been closed 2014-09-25 00:15:52 +09:00
Tatsuhiro Tsujikawa fd07f5e142 src: Add utility APIs to asio_http2.h; add asio-sv2 example to serve files 2014-09-24 23:05:13 +09:00
Tatsuhiro Tsujikawa 3651467c71 src: Silence compiler warning 2014-09-24 00:57:43 +09:00
Tatsuhiro Tsujikawa 5d0bf4cc84 Add C++ library libnghttp2_asio on top of libnghttp2
The libnghttp2_asio library is C++ library built on top of libnghttp2.
Currently, it has server API and easily create HTTP/2 server using
node.js like API calls.  See the example server source code in
examples/asio-sv.cc.  The library depends on Boost::ASIO library.
2014-09-24 00:45:40 +09:00
Tatsuhiro Tsujikawa 446f8f13aa src: Move libevent related helper functions to libevent_util 2014-09-24 00:45:40 +09:00
Tatsuhiro Tsujikawa a9b74261b6 nghttpd: Rewrite using bufferevent (again) for simplicity 2014-09-19 00:58:32 +09:00
Tatsuhiro Tsujikawa 83309b6391 nghttpx: Reduce epoll_ctl call 2014-09-18 23:56:01 +09:00
Tatsuhiro Tsujikawa 23dd428d65 nghttpx: Reset timeouts when either read or write succeeds
See previous commit message why we need this.
2014-09-18 23:19:28 +09:00
Tatsuhiro Tsujikawa b305495a75 nghttpx: Reset both timeouts when either read or write succeeds
Previously read and write timeouts work independently.  When we are
writing response to the client, read timeout still ticks (e.g., HTTP/2
or tunneled HTTPS connection).  So read timeout may occur during long
download.  This commit fixes this issue.  This commit only fixes the
upstream part.  We need similar fix for the downstream.
2014-09-18 23:03:36 +09:00
Tatsuhiro Tsujikawa 44ac571037 nghttpx: Add more handling situation where response ends before request 2014-09-17 22:53:29 +09:00
Tatsuhiro Tsujikawa 5bff48a15a nghttpx: Call upstream resume_read after sending pending request to backend
With the combination of HTTP/1 upstream and HTTP/2 downstream,
downstream tells SHRPX_NO_BUFFER while connecting to the backend
server.  Previously, we did not call upstream resume_read and upload
was blocked.  This commit now calls upstream resume_read to unblock.
This commit also remove pending output buffer size of Http2Session
when calculating downstream connection's buffer is full.  This is
desirable since we only operate resume_read by stream basis.
2014-09-17 22:36:42 +09:00
Tatsuhiro Tsujikawa e4751a798a Replace auto_delete* with defer 2014-09-16 23:39:38 +09:00
Tatsuhiro Tsujikawa d00d4d647d Compile with android NDK r10b 32bit target
Android does not have _Exit.  We detect this and use _exit instead.
clang-3.4 has an issue around undefined reference to
__atomic_fetch_add_4, so we stick to gcc-4.8 for now.
2014-09-14 21:32:53 +09:00
Tatsuhiro Tsujikawa 901de5fbce Add nghttp2_option_set_recv_client_preface()
By default, nghttp2 library only handles HTTP/2 frames and does not
recognize first 24 bytes of client connection preface. This design
choice is done due to the fact that server may want to detect the
application protocol based on first few bytes on clear text
communication. But for simple servers which only speak HTTP/2, it is
easier for developers if nghttp2 library takes care of client
connection preface.

If this option is used with nonzero val, nghttp2 library checks first
24 bytes client connection preface. If it is not a valid one,
nghttp2_session_recv() and nghttp2_session_mem_recv() will return
error NGHTTP2_ERR_BAD_PREFACE, which is fatal error.
2014-09-13 19:50:44 +09:00
Tatsuhiro Tsujikawa 85f605f20d src: Check availability of ENONET 2014-09-02 01:00:27 +09:00
Tatsuhiro Tsujikawa d8c0d87c90 src: Add missing SETTINGS ID to debug output
SETTINGS_MAX_FRAME_SIZE and SETTINGS_MAX_HEADER_LIST_SIZE are 2
missing SETTINGS IDs and now they are shown correctly.
2014-08-29 00:14:10 +09:00
Tatsuhiro Tsujikawa 8890e593e6 src: Add util::array_size 2014-08-28 00:45:12 +09:00
Tatsuhiro Tsujikawa f8471a5f45 nghttpx: Move --backend-http-proxy-uri to Connections section 2014-08-27 23:37:54 +09:00
Tatsuhiro Tsujikawa f34cbf9b45 tests: Include config.h 2014-08-27 23:36:57 +09:00
Tatsuhiro Tsujikawa a23a705121 nghttpx: Strict integer config validation 2014-08-27 23:36:36 +09:00
Tatsuhiro Tsujikawa 822ec75814 nghttpx: Add --listener-disable-timeout option 2014-08-27 22:34:00 +09:00
Tatsuhiro Tsujikawa 0209b7c083 nghttpx: Fix location rewrite is failed because request headers are empty
Previously we empties request headers after they are sent to
downstream in order to free memory.  But it turns out that we use
request headers when rewriting location header response field.  Also
user reported that request headers are useful to add new features.
This commits defers the deletion of request headers to the point when
response headers are deleted (which is after response headers are sent
to upstream client).
2014-08-27 21:25:25 +09:00
Tatsuhiro Tsujikawa 223242b512 nghttpx: Don't consume response data in downstream on_stream_close_callback
Even after on_stream_close_callback, Http2DownstreamConnection is
still alive and upstream keeps sending response to the client.  The
consumed bytes are processed normally (data_source_read_callback) and
also we have a code to consume all allocated bytes for
Http2DownstreamConnection object when it is deleted.  This means that
we don't need to and should not consume response data in downstream
on_stream_close_callback.  If we do, we may get assertion error in
Http2DownstreamConnection::resume_read().
2014-08-26 22:16:19 +09:00
Tatsuhiro Tsujikawa 82bc7198e6 Change nghttp2_session_get_stream_remote_window_size behavior
Now it returns only stream's available remote window size, without
considering connection level window size.  For connection-level window
size, nghttp2_session_get_remote_window_size() is added by this
commit.  To get old behavior of
nghttp2_session_get_stream_remote_window_size() is use
min(nghttp2_session_get_stream_remote_window_size(),
nghttp2_session_get_remote_window_size()).  The reason of this change
is that it is desirable to know just stream level window size without
taking into connection level window size.  This is useful for
debugging purpose.
2014-08-25 21:44:22 +09:00
Tatsuhiro Tsujikawa 53ee21caa9 Remove nghttp2_on_unknown_frame_recv_callback
It is not used by library for a while.  It could be used to pass
unsupported extension frames to application, but its interface
requires library to buffer entire frame, which we'd like to avoid.
For unsupported extension frames, we will add new callbacks which does
not require buffering if they are required.
2014-08-25 21:24:04 +09:00
Tatsuhiro Tsujikawa 31528b6267 Use uint32_t for HTTP/2 error_code
h2-14 now allows extensions to define new error codes.  To allow
application callback to access such error codes, we uses uint32_t as
error_code type for structs and function parameters.  Previously we
treated unknown error code as INTERNAL_ERROR, but this change removes
this and unknown error code is passed to application callback as is.
2014-08-25 21:24:04 +09:00
Tatsuhiro Tsujikawa ab5b81bee1 Hide nghttp2_session_callbacks details and provide setter like functions
To make it possible to add new callbacks without bumping so name, we
decided to hide details of nghttp2_session_callbacks.  We provide
setter like functions to set individual callback function.
2014-08-25 21:24:04 +09:00
Tatsuhiro Tsujikawa 1673ae2c99 src: Add 308 Permanent Redirect (RFC 7238) 2014-08-24 22:56:48 +09:00
Tatsuhiro Tsujikawa d5da7611fa nghttpx: Remove unused member function and variable 2014-08-24 22:27:10 +09:00
Tatsuhiro Tsujikawa 9ad2c0887e nghttpx: Use _Exit() instead of exit() when execve is failed in child process 2014-08-23 18:15:47 +09:00
Tatsuhiro Tsujikawa d5dcbf6f3b nghttpx: Fix possible flow control issue
Previously we only update consumed flow control window when number of
bytes read in nghttp2 and spdylay callback is 0.  Now we notify
nghttp2 library the consumed bytes even if number of bytes read > 0.
This change also uses newly added spdylay_session_consume() API, so we
require spdylay >= 1.3.0.
2014-08-21 21:22:16 +09:00
Tatsuhiro Tsujikawa 69b9ce6b68 nghttpx: Fix possible deadlock due to exhaustion of send window 2014-08-20 01:39:07 +09:00
Tatsuhiro Tsujikawa c81e87bf37 nghttpx: Fix dereference after null check 2014-08-20 00:17:50 +09:00
Tatsuhiro Tsujikawa 97533c966d nghttpx: Fix gcc compiler warning 2014-08-20 00:09:18 +09:00
Tatsuhiro Tsujikawa d6b495f2a7 nghttpx: Returns 503 if downstream connect fail for https upstream 2014-08-19 23:41:53 +09:00
Tatsuhiro Tsujikawa c7e9fe8154 nghttpx: Implement connection blocker for HTTP/1 backend 2014-08-19 23:36:04 +09:00
Tatsuhiro Tsujikawa fb62a5ed4f nghttpx: Use pointer for worker_config 2014-08-19 22:29:44 +09:00
Tatsuhiro Tsujikawa 345121975a nghttpx: Handle socket creation error 2014-08-19 22:29:44 +09:00