384 Commits

Author SHA1 Message Date
Max Inden
b36a12414d benches: Update to new bench_with_input function 2021-02-01 18:33:51 +01:00
Max Inden
2ba14dd043 Merge pull request #101 from mxinden/unit-tests
src/tests: Write and read concurrently
2021-02-01 14:21:30 +01:00
Max Inden
168d4f5a94 src/tests: Restrict number of quickcheck runs
With quickcheck iterations potentially taking long, restrict number of
iterations per test to 10.
2021-01-29 16:48:39 +01:00
Max Inden
13720cd15b src/tests: Write and read concurrently
Most of the tests in `src/tests.rs` have the structure of a client
sending data to a server which in turn echoes the data back to the
client which reads it in full and compares it to what it initially sent.

Some of the tests use randomly generated configurations where the
`WindowUpdateMode` can be either `OnRead` or `OnReceive`. When using
`WindowUpdateMode::OnRead` the client can not first send all data to the
server and only then receive all data from the server. In such case the
server would eventually exhaust its window to the client, thus not being
able to forward bytes to the client, thus not accepting new bytes from
the client, thus the client would be blocked on sending and thus the
whole test would deadlock.

With this commit the client writes and reads concurrently and thus does
not run into a deadlock when executing with `WindowUpdateMode::OnRead`.
2021-01-29 16:48:36 +01:00
Toralf Wittner
4712012b3b Merge branch 'develop' into master 2020-09-08 12:59:15 +02:00
Toralf Wittner
df476efbaf Remove additive flag (#98) 2020-09-08 12:58:20 +02:00
Toralf Wittner
3e52ea4e56 Merge branch 'develop' into master 2020-09-08 12:31:01 +02:00
Toralf Wittner
e2644c2012 Always assume additive flag. (#96) 2020-09-08 12:20:17 +02:00
Toralf Wittner
a6c6e2927e Delete .travis.yml 2020-09-08 12:00:10 +02:00
Toralf Wittner
cc2b723940 Create rust.yml 2020-09-08 11:57:09 +02:00
Toralf Wittner
2acd2182ac Merge branch 'develop' into master 2020-09-08 11:30:55 +02:00
Toralf Wittner
7ba9bb9c3e Set additive flag in initial window update. (#95) 2020-09-08 11:29:42 +02:00
Toralf Wittner
4525231aeb Merge branch 'develop' into master 2020-09-08 11:18:23 +02:00
Toralf Wittner
60b15bbb66 Merge pull request #94 from twittner/yamux-0.5.0
Add additive flag.
2020-09-08 11:17:44 +02:00
Toralf Wittner
ad986a8bde Update CHANGELOG and increment version to 0.5.0 2020-09-07 16:34:28 +02:00
Toralf Wittner
2380b4379b Merge branch 'develop' into yamux-0.5.0 2020-09-02 11:17:34 +02:00
Toralf Wittner
0558df3680 Merge pull request #97 from koushiro/koushiro/update-parking_lot
Update parking_lot to 0.11
2020-09-01 12:28:56 +02:00
koushiro
c8728af93e Update parking_lot to 0.11
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2020-08-30 13:24:20 +08:00
Toralf Wittner
eeebf9b2af Add additive flag.
If present a received initial window update is intepreted as additive,
i.e. the amount of credit is added to the default of 256 KiB.
2020-08-27 11:46:29 +02:00
Toralf Wittner
a773f603da Merge branch 'develop' into master 2020-08-27 11:30:57 +02:00
Toralf Wittner
56a97af088 Update CHANGELOG and increment version to 0.4.9 2020-08-27 11:30:35 +02:00
Toralf Wittner
1df9700ad6 Merge pull request #93 from twittner/another-fix
If `lazy_open` use the default receive window.
2020-08-27 09:10:08 +02:00
Toralf Wittner
f75d8218ed If lazy_open use the default receive window.
The current implementation always uses the configured receive window
for the remote. However, when not sending the initial window update,
this means that the remote stops sending before having used up its
credit which it assumes matches the default receive window as it has
not received an initial window update. Therefore, if `lazy_open` is
true, the default receive window must be used initially.
2020-08-26 17:53:37 +02:00
Toralf Wittner
3753407011 Merge branch 'develop' into master 2020-08-26 11:38:50 +02:00
Toralf Wittner
81c081c27c Update CHANGELOG and increment version to 0.4.8 2020-08-26 11:38:30 +02:00
Toralf Wittner
64ac639a47 Merge pull request #91 from twittner/fix_lazy_open
Send window update for initial data.
2020-08-26 11:33:35 +02:00
Toralf Wittner
d9789ecb60 Set ACK flag if window update is sent immediately.
Only tell the stream to do so later if no update is sent, so it will
do so eventually when sending its first frame.
2020-08-26 10:17:35 +02:00
Toralf Wittner
f404e4622f Send window update for initial data.
PR #73 introduced a lazy open option to defer sending the initial
frame when actual data is sent. If enabled and the initial data
size equals DEFAULT_CREDIT (i.e. 256 KiB), it is necessary to
immediately send a window update back when accepting such a
stream, but only if window update mode is `OnReceive`, otherwise
the update will be sent when the stream data is consumed.

With more options there are more ways how things can influence
each other, so I have changed some tests to work with randomly
generated configurations to test more combinations.
2020-08-25 18:45:42 +02:00
Toralf Wittner
747ad34b8b Merge pull request #88 from mxinden/receive-window
src/lib: Document that receive window is per stream
2020-07-07 10:25:25 +02:00
Max Inden
f2aa2b74a4 src/lib: Document that receive window is per stream 2020-07-06 21:47:58 +02:00
Toralf Wittner
1ed5538147 Merge branch 'develop' 2020-06-18 13:47:24 +02:00
Toralf Wittner
20dfbc54da Merge pull request #86 from twittner/minor
Minor changes
2020-06-18 13:46:43 +02:00
Toralf Wittner
c1973672a0 Update CHANGELOG and increment version to 0.4.7 2020-06-18 13:12:25 +02:00
Toralf Wittner
f1cb3283fa Replace Stream::pending with Stream::window_update.
The field `Stream::pending` is already specific to window updates and
in fact of type `Option<Frame<WindowUpdate>>`. The method
`Stream::send_pending` also modifies the stream's receive window after
a successful delivery, so because of all this window update specific
logic, the rather generic name "pending" is hereby replaced with
"window_update" and "send_pending" with "send_pending_window_update".
2020-06-18 13:10:04 +02:00
Toralf Wittner
90f818ca47 Merge pull request #85 from twittner/fix-window-update-sending
In 14a814e we missed updating the window.
2020-06-18 12:31:31 +02:00
Toralf Wittner
66725f1a9a In 14a814e we missed updating the window.
While we reset the receive window in `Stream::send_pending` we forgot
to do so in case the initial send operation was successful. Because of
that we potentially issued multiple window updates to the remote which
would then have too much credit and their subsequent frames might even
be larger than the max. stream buffer size.

To fix this we now only use `Stream::send_pending` to send window
updates, rather than modifying the window in two more places.
2020-06-18 11:47:50 +02:00
Toralf Wittner
bbc427766b Merge branch 'develop' 2020-06-17 14:27:52 +02:00
Toralf Wittner
6650c5a012 Update CHANGELOG and increment version to 0.4.6 2020-06-17 14:25:35 +02:00
Toralf Wittner
a37ffcd575 Merge pull request #84 from twittner/gc
Reset dropped stream if window == 0.
2020-06-17 12:30:32 +02:00
Toralf Wittner
14a814e693 Reset dropped stream if window == 0.
If `WindowUpdateMode` is `OnRead` and a stream is in state `SendClosed`
when being dropped, we consider its buffer to determine if the remote
may be blocked and needs to receive a reset frame. This is a bit odd as
we could and should rather look at the stream's actual window size.
If it is 0 we know that the remote may be blocked and since the
stream is dropped no further window updates are forthcoming from our
side, hence a RST frame should be sent right away. If it is > 0 the
remote either has credit left or if it has not then the socket buffer
must contain more data and we will answer with a RST for any unknown
stream, so no action is necessary.

So why are we not looking a `window`? The reason is that we currently
update the window before the window update is enqueued and if `poll_read`
is not called again it may never be. To fix this we must ensure that the
value of window is only updated after the window update has been
enqueued properly so we know it will eventually be sent to the remote.
Once we have ensured that it is done correctly we may safely look at
`window` in `garbage_collect` and proceed as outlined above.
2020-06-15 13:43:44 +02:00
Toralf Wittner
33bbe5a99e Merge pull request #83 from twittner/tokio
Use tokio in tests.
2020-06-13 21:41:06 +02:00
Toralf Wittner
96246cec0a Use tokio in tests. 2020-06-12 13:59:20 +02:00
Toralf Wittner
2ae38a4371 Merge branch 'develop' 2020-03-23 12:13:06 +01:00
Toralf Wittner
d60fca82f1 Update CHANGELOG and increment version to 0.4.5 2020-03-23 12:11:33 +01:00
Toralf Wittner
5b1495ed80 Merge pull request #80 from twittner/is-closed-flag
Add `Connection::is_closed` flag.
2020-03-23 10:44:16 +01:00
Toralf Wittner
b72d93ed51 Merge pull request #78 from twittner/rm-thiserror
Remove `thiserror` dependency.
2020-03-23 10:43:52 +01:00
Toralf Wittner
9f0aa36c3b Add Connection::is_closed flag.
This PR adds an `is_closed` flag to `Connection` and if `true`,
`Connection::next_stream` returns immediately with `Ok(None)` to help
clients that keep calling this method after they received an error.

While the API contract of `Connection::next_stream` already states that
after `Ok(None)` or `Err(_)` have been returned no further invocations
of `next_stream` must happen, it is conceivable that clients still do
this (e.g. trying to go on after `Err(_)`) so it seems advisable to
handle this case in a more explicit way.
2020-03-20 16:07:47 +01:00
Toralf Wittner
ea7779646e Remove thiserror dependency.
Also disable default features for futures dependency so we do not
always depend on proc-macros crates.
2020-03-20 13:06:38 +01:00
Toralf Wittner
3dc4ca3aad Merge pull request #77 from twittner/rm-bytes
Remove `bytes` dependency.
2020-03-19 11:01:56 +01:00
Toralf Wittner
3baa35cfb4 Improve some comments. 2020-03-18 16:43:53 +01:00