Commit Graph

625 Commits

Author SHA1 Message Date
Robert Ying
b116605560 Check whether the send side is not idle, not the recv side (#313)
* Check whether the send side is not idle, not the recv side
* Ensure sure we're handling window updates for the right side
* Add failing test
2018-10-16 12:03:56 -07:00
Carl Lerche
a4ed6155ac Check minimal versions (#322) 2018-10-16 12:03:29 -07:00
Geoffry Song
ea8b8ac2fd Avoid prematurely unlinking streams in send_reset, in some cases. (#319)
Because `send_reset` called `recv_err`, which calls `reclaim_all_capacity`,
which eventually calls `transition(stream, ..)` -- all of which happens _before_
the RESET frame is enqueued -- it was possible for the stream to get unlinked
from the store (if there was any connection-level capacity to reassign). This
could then cause the stream to get "leaked" on drop/EOF since it would no longer
be iterated.

Fix this by delaying the call to `reclaim_all_capacity` _after_ enqueueing the
RESET frame.

A test demonstrating the issue is included.
2018-10-16 11:59:22 -07:00
Carl Lerche
9bbbe7ebd5 Disable length_delimited deprecation warning. (#321)
Until tokio-rs/tokio#680 is resolved, we should allow using deprecated
APIs in the codec module.
2018-10-16 08:21:23 -07:00
Eliza Weisman
00ca534c4a Update examples to use new Tokio (#316)
The old `tokio-core` crate is deprecated in favour of the `tokio` crate,
which also provides the new multithreaded Tokio runtime. Although `h2`
is generic over the runtime, the examples do depend on `tokio`. 

This branch update the example code to use the new `tokio` library
rather than `tokio-core`. It also updates the examples in `RustDoc`.

For the most part, this was pretty trivial --- simply replacing
`handle.spawn(...)` with `tokio::spawn(...)` and `core.run(...)` with
`tokio::run(...)`. There were a couple of cases where error and item
types from spawned futures had to be mapped to `(), ()`. Alternatively,
this could have been avoided by using the single-threaded runtime and
calling `block_on` instead to await the value of those futures, but I
thought it was better to reduce the amount of tokio-specific code in the
examples.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-09-25 14:33:49 -07:00
samamill
12e0d26945 Added functions to access io::Error in h2::Error (#311)
Fixes #310
2018-09-24 10:12:46 -07:00
Michael Beaumont
586106adf2 Fix push promise frame parsing (#309) 2018-09-17 14:55:37 -07:00
Eliza Weisman
2b960b897d Add Reset::INTERNAL_ERROR helper to test support (#308)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-09-13 16:33:44 -07:00
Sean McArthur
d464c6bfff set deny(warnings) only when cfg(test) (#307)
This should fix building the docs on docs.rs.
2018-08-15 11:05:16 -07:00
Sean McArthur
b0db515bdd fix some autolinks that weren't resolving in docs (#305) 2018-08-10 14:27:45 -07:00
Steven Fackler
66a5d113d4 Shutdown the stream along with connection (#304)
This will in particular send close notify alerts for TLS streams.
2018-08-09 10:36:30 -07:00
Sean McArthur
3b57049792 v0.1.12 2018-08-08 16:05:27 -07:00
Geoffry Song
e6c841c8ba Fix the initial send window size. (#301)
Closes #298.
2018-08-08 15:43:56 -07:00
Sean McArthur
12028cc418 fix panic when calling reserve_capacity after connection closes (#302) 2018-08-08 15:43:47 -07:00
Geoffry Song
d2aa9197f9 Fix the handling of incoming SETTINGS_INITIAL_WINDOW_SIZE. (#299) 2018-08-03 16:00:13 -07:00
Eliza Weisman
78ab6167c4 v0.1.11 2018-07-31 11:44:01 -07:00
Sean McArthur
c564273986 fix graceful shutdown to close once idle (#296) 2018-07-30 21:42:00 -07:00
Geoffry Song
fdfb873438 Prevent pending_open streams from being released. (#295)
* Prevent `pending_open` streams from being released.

This fixes a panic that would otherwise occur in some cases. A test
demonstrating said panic is included.

* Clear the pending_open queue together with everything else.
2018-07-23 15:41:54 -07:00
Eliza Weisman
f3806d5144 Add stream_id accessors to public API types (#292)
Problem:

Applications may want to access the underlying h2 stream ID for
diagnostics, etc. Stream IDs were not previously exposed in public APIs.

Solution:

Added a new public `share::StreamId` type, which has a more restricted 
API than the internal `frame::StreamId` type. The public API types 
`SendStream`, `RecvStream`, `ReleaseCapacity`, 
`client::ResponseFuture`, and `server::SendResponse` now all have 
`stream_id` methods which return the stream ID of the corresponding 
stream.

Closes #289.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-07-12 21:01:57 -07:00
Jake Goulding
41aae14c64 Do not distribute the fixtures in published crates (#290) 2018-06-20 17:09:33 -07:00
Carl Lerche
e78e7f152d Bump version to v0.1.10 (#287) 2018-06-18 12:01:35 -07:00
Carl Lerche
df69c0455a Fix spurrious test failure (#288)
There was a race condition in the test where the server connection
sometimes closed before the final client opereation. This triggered an
unwrap in the test.

This patch updates the test to ensuree that the mock server connection
stays open until the client test is complete.
2018-06-18 11:20:18 -07:00
Arvid E. Picciani
74a5e072fe Fix tight loop on aborted connection (#285)
When the underlying IO returns 0 on read, we must stop polling it since
it's closed. Otherwise we'll be stuck in a tight loop.

this fixes https://github.com/sfackler/rust-openssl/issues/949
2018-06-15 16:04:13 -07:00
Arvid E. Picciani
2b59803866 fix doc typo (#286) 2018-06-15 15:40:26 -07:00
Geoffry Song
23234fa14f Promote SendRequest::pending to an OpaqueStreamRef. (#281)
Because `self.pending` doesn't necessarily get cleaned up in a timely fashion -
rather, only when the user calls `poll_ready()` - it was possible for it to
refer to a stream that has already been closed. This would lead to a panic the
next time that `poll_ready()` was called.

Instead, use an `OpaqueStreamRef`, bumping the refcount.

A change to an existing test is included which demonstrates the issue.
2018-06-06 10:16:22 -07:00
Sean McArthur
1b9469ff75 v0.1.9 (#280) 2018-05-31 20:42:52 +02:00
Sean McArthur
3a4633d205 add SendResponse::poll_reset and SendStream::poll_reset to listen for reset streams (#279) 2018-05-30 22:57:43 +02:00
Carl Lerche
82addd6369 Bump version to v0.1.8 (#278) 2018-05-23 11:34:23 -07:00
johnklai1
6e63d7bae2 Wakeup waiting tasks when transitioning a stream from pending_open (#277) 2018-05-22 15:42:41 -07:00
Carl Lerche
a955a15091 Bump version to v0.1.7 (#276) 2018-05-14 10:35:22 -07:00
Carl Lerche
bb454e017c Enforce monotonic stream IDs for push promises (#275)
Previously, monotonic stream IDs (spec 5.1.1) for push promises were not
enforced. This was due to push promises going through an entirely
separate code path than normally initiated streams.

This patch unifies the code path for initializing streams via both
HEADERS and PUSH_PROMISE. This is done by first calling `recv.open` in
both cases.

Closes #272
2018-05-14 10:20:57 -07:00
Carl Lerche
173f9a67e7 Include fuzz testing setup (#274) 2018-05-10 14:48:02 -07:00
Geoffry Song
571bb14556 Be more lenient with streams in the pending_send queue. (#261)
The `is_peer_reset()` check doesn't quite cover all the cases where we call
`clear_queue`, such as when we call `recv_err`. Instead of trying to make the
check more precise, let's gracefully handle spurious entries in the queue.
2018-05-09 20:01:39 -07:00
Carl Lerche
cf62b783e0 Misc bug fixes related to stream state (#273)
This patch includes two new significant debug assertions:

* Assert stream counts are zero when the connection finalizes.
* Assert all stream state has been released when the connection is 
  dropped.

These two assertions were added in an effort to test the fix provided
by #261. In doing so, many related bugs have been discovered and fixed.
The details related to these bugs can be found in #273.
2018-05-09 15:03:21 -07:00
Carl Lerche
b4383b6a8c Add more stream state tests (#271) 2018-05-04 14:11:40 -07:00
Carl Lerche
8a9dfd14dc Move tests and support utilities to sub crates. (#268)
These crates will not be published to crates.io, but moving them allows
`tower-h2` to also depend on the test utilities.
2018-05-03 13:08:39 -07:00
Dirkjan Ochtman
51f6a12454 Fix links to handshake() documentation (#265) 2018-04-30 10:32:39 -07:00
Sean McArthur
e8fcd34476 change from deprecated Buf::put_*<E> to put_*_be (#267) 2018-04-27 14:35:28 -07:00
Sean McArthur
fadec67fdf prevent a leak of 'active streams' if client request has user error (#266) 2018-04-26 18:20:32 -07:00
Carl Lerche
279dd93354 Bump version to v0.1.6 (#264) 2018-04-24 20:47:17 -07:00
Geoffry Song
558e6b6e6c Avoid reclaiming frames for dead streams. (#262)
In `clear_queue` we drop all the queued frames for a stream, but this doesn't
take into account a buffered frame inside of the `FramedWrite`. This can lead
to a panic when `reclaim_frame` tries to recover a frame onto a stream that has
already been destroyed, or in general cause wrong behaviour.

Instead, let's keep track of what frame is currently in-flight; then, when we
`clear_queue` a stream with an in-flight data frame, mark the frame to be
dropped instead of reclaimed.
2018-04-24 16:52:24 -07:00
Geoffry Song
11f914150e Add some missing bounds checks. (#260) 2018-04-23 14:38:42 -07:00
Eliza Weisman
040f391479 Reset any queued stream on receipt of remote reset (#258)
Fixes #256.

This PR changes `state::recv_reset` so any closed stream with queued send is immediately reset (and thus, the queue is cleared) on receipt of a `RST_STREAM` frame from the remote. 

This fixes the panic encountered by the test @goffrie posted in #256, where the stream is scheduled to close, receives a `RST_STREAM` frame, and sets the buffered capacity to 0, but isn't removed from the send queue, so we hit an assertion (or wrap, if debug assertions are disabled) when subtracting a sent frame's size from the buffered size.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-04-16 16:17:29 -07:00
Oliver Gould
fabae35311 Bump version to v0.1.5 (#255) 2018-04-06 18:41:27 -07:00
Sean McArthur
dca336f8b2 send proper max stream ID in graceful goaway (#254) 2018-04-06 15:51:34 -07:00
Sean McArthur
60749db680 Bump version to v0.1.4 2018-04-05 13:13:26 -07:00
Sean McArthur
65f69a3062 add ability to synchronize in tests
- Adds `wait_for` that takes another future to signal the mock
  should continue.
- Adds `yield_once` to allow one chain of futures to yield to the
  other.
2018-03-29 13:51:30 -07:00
Sean McArthur
1c5d4ded50 Add Graceful Shutdown support
If graceful shutdown is initiated, a GOAWAY of the max stream ID - 1 is
sent, followed by a PING frame, to measure RTT. When the PING is ACKed,
the connection sends a new GOAWAY with the proper last processed stream
ID. From there, once all active streams have completely, the connection
will finally close.
2018-03-29 13:51:30 -07:00
Oliver Gould
01d81b46c2 Add initial_connection_window_size to Builders (#249)
There is currently no way to configure the initial target window size
for connections. The `Builder::initial_connection_window_size` utilities
make this configurable so that all new connections have this target
window size set.
2018-03-28 14:46:56 -07:00
Carl Lerche
430d28723f Bump version to v0.1.3 (#248) 2018-03-28 12:50:46 -07:00