Commit Graph

5 Commits

Author SHA1 Message Date
Taiki Endo b12a3e3ae9
Remove uses of pin_project::project attribute (#458)
pin-project will deprecate the project attribute due to some unfixable
limitations.

Refs: https://github.com/taiki-e/pin-project/issues/225
2020-06-15 12:38:34 -04:00
Eliza Weisman 8752a38117
util: fix oneshot dropping pending services immediately (#447)
## Motivation

Commit #330 introduced a regression when porting `tower-util::Oneshot`
from `futures` 0.1 to `std::future`. The *intended* behavior is that a
oneshot future should repeatedly call `poll_ready` on the oneshotted
service until it is ready, and then call the service and drive the
returned future. However, #330 inadvertently changed the oneshot future
to poll the service _once_, call it if it is ready, and then drop it,
regardless of its readiness.

In the #330 version of oneshot, an `Option` is used to store the
request while waiting for the service to become ready, so that it can be
`take`n and moved into the service's `call`. However, the `Option`
contains both the request _and_ the service itself, and is taken the
first time the service is polled. `futures::ready!` is then used when
polling the service, so the method returns immediate if it is not ready.
This means that the service itself (and the request), which were taken
out of the `Option`, will be dropped, and if the oneshot future is
polled again, it will panic.

## Solution

This commit changes the `Oneshot` future so that only the request lives
in the `Option`, and it is only taken when the service is called, rather
than every time it is polled. This fixes the bug.

I've also added a test for this which fails against master, but passes
after this change.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-04-23 16:07:48 -07:00
Jon Gjengset 8df2a3e410
step 1: move all things to where they're going
Note that this also moves all crates from `log` to `tracing`.
It also does not set any dependencies as optional.
2020-03-31 13:31:21 -04:00
Carl Lerche 3a407c2775
Move misc types (#213) 2019-03-27 19:56:44 -07:00
Carl Lerche 5607313192
Minor `tower` crate re-org (#201)
- Rename `tower::ext` -> `tower::util`.
- Re-export structs from `tower-service-util` in `tower::util`.
- Re-export `tower_service::Service` at root.
2019-03-20 09:17:59 -07:00