Commit Graph

643 Commits

Author SHA1 Message Date
Sean McArthur
e3a73f726e Add user PING support (#346)
- Add `share::PingPong`, which can send `Ping`s, and poll for the `Pong`
  from the peer.
2019-02-18 15:59:11 -08:00
Sean McArthur
8a0b7ff64f Loosen bounds on Handshake struct (#343) 2019-02-07 13:03:53 -08:00
Sean McArthur
74f040f5bf v0.1.16 (#344) 2019-01-24 10:37:47 -08:00
Max
d6a8a70ba9 Fixed incorrect order of arguments in send_reset trace. (#341) 2019-01-24 10:10:51 -08:00
Eliza Weisman
4b81e528d5 Log more information when rejecting malformed pseudo-headers (#342)
Currently, when a `h2` server receives a HEADERS frame with malformed
pseudo-headers, it logs which pseudo-heade was malformed at the debug
level before sending a reset. This behaviour is correct. However, it can
be difficult to debug misbehaving clients, as the server's log message
doesn't include the *value* of the invalid pseudo-header, or indicate
*why* it was incorrect. 

This branch changes the log message to include both the value of the
malformed header and the error that caused it to be rejected. 

For example, here is the output from the test
`server::recv_invalid_authority`, before and after making this change.

Before:
```
...
DEBUG 2019-01-23T19:16:28Z: h2::server: malformed headers: malformed authority
...
```

After:
```
...
DEBUG 2019-01-23T19:15:37Z: h2::server: malformed headers: malformed authority ("not:a/good authority"): invalid uri character
...
```

Note that it was necessary to clone the value of each pseudo-header
before passing it to the `uri::{Scheme, Authority, Path}::from_shared`
constructors, so that the value could be logged if those functions
return errors. However, since the pseudo-headers are internally
represented using `Bytes`, this should just increase the reference count
rather than copy the string, so I thought this was acceptable. 

If even a ref-count bump has an undesirable performance overhead, we
could consider using
```rust
if log_enabled!(Level::Debug) {
    // ...
}
```
to only clone if the message will be logged, but this makes the code
somewhat significantly more complicated. Therefore, I decided to punt on
that unless requested by a reviewer.

See also linkerd/linkerd2#2133

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-01-23 11:44:32 -08:00
Carl Lerche
78c39d8e65 Bump version to v0.1.15 (#339) 2019-01-13 09:53:19 -08:00
Eliza Weisman
d6e1fbeed8 Fix race in stream ref count (#338)
Fixes #326
2019-01-11 22:41:35 -08:00
Sean McArthur
61adb3570e v0.1.14 2018-12-05 10:05:46 -08:00
Sean McArthur
c7d4182ffe Release closed streams capacity back to connection (#334)
Previously, any streams that were dropped or closed while not having
consumed the inflight received window capacity would simply leak that
capacity for the connection. This could easily happen if a `RecvStream`
were dropped before fully consuming the data, and therefore a user would
have no idea how much capacity to release in the first place. This
resulted in stalled connections that would never have capacity again.
2018-12-05 09:44:20 -08:00
Igor Gnatenko
545ff1e7dd exclude more CI files and bump webpki to released version (#331) 2018-11-29 21:55:08 -08:00
Carl Lerche
8387355e1b Avoid locking when printing (#333)
* Avoid locking when printing

It is not obvious that attempting to print the
value of a struct could cause a deadlock. To avoid
this, this patch does not lock the mutex when generating
a debug representation of the h2 struct.

* Use try_lock
2018-11-29 21:50:53 -08:00
Sean McArthur
e656c42353 fix inverted split for DATA frame padding (#330) 2018-11-05 10:20:09 -08:00
Sean McArthur
1a8015da4a Reduce noise in Debug for Frame (#329) 2018-11-01 13:26:55 -07:00
Geoffry Song
4321caf6b3 Augment the fuzzer to open multiple concurrent streams. (#328)
This is how I found #319 and #320.
2018-10-29 14:07:08 -07:00
Michael Beaumont
fc5efe73d6 Add OpaqueStreamRef constructor (#325)
Closes #318
2018-10-17 23:09:28 -07:00
Carl Lerche
80b4ec5073 Bump version to v0.1.13 (#324) 2018-10-16 14:41:23 -07:00
Michael Beaumont
6b23542a55 Add client support for server push (#314)
This patch exposes push promises to the client API.

Closes #252
2018-10-16 12:51:08 -07:00
Geoffry Song
6d8554a23c Reassign capacity from reset streams. (#320)
I believe this was an oversight - a stream that is reset can still have some
capacity assigned to it (e.g. if said capacity was assigned in the same poll as
the reset), which should be redistributed.
2018-10-16 12:14:42 -07:00
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