Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple pipe-server hanging forever #15

Open
hankbao opened this issue Aug 6, 2019 · 3 comments
Open

Simple pipe-server hanging forever #15

hankbao opened this issue Aug 6, 2019 · 3 comments

Comments

@hankbao
Copy link

hankbao commented Aug 6, 2019

Thanks for providing this crate. I'm new to rust and tokio, so please forgive me if this looks dumb.

However, I encountered a hanging issue when using it on Windows. I'm building an IpcServer as a Future from an Incoming and then I run it with tokio. I got an IPC client which can connect (with CreateFile) to the pipe successfully. The client can even write to the pipe asynchronously. But IpcServer::poll never fires again except for the first time.

I'm pretty sure this is related to my code. Would you please kindly point it out? Thanks.

use futures::prelude::*;
use parity_tokio_ipc::{Endpoint, Incoming};
use tokio;
use std::io::ErrorKind;

const DAEMON_PIPE_NAME: &str = "\\\\.\\pipe\\TestPipe\\ServiceControl\0";

pub struct IpcServer {
    incoming: Incoming,
}

impl IpcServer {
    pub fn new() -> Self {
        let endpoint = Endpoint::new(DAEMON_PIPE_NAME.to_string());

        let incoming = match endpoint.incoming(&tokio::reactor::Handle::default()) {
            Ok(inc) => inc,
            Err(e) => {
                println!("IpcServer: Endpoint creation failed {:?}", e);
                panic!("Check the pipe");
            }
        };

        IpcServer {
            incoming,
        }
    }
}

impl Future for IpcServer {
    type Item = ();
    type Error = ();

    fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
        loop {
            match self.incoming.poll() {
                Ok(Async::Ready(Some((_, _)))) => {
                    println!("IpcServer: new pipe incoming");
                    continue;
                }

                Ok(Async::Ready(None)) => {
                    panic!("impossible!");
                }

                Ok(Async::NotReady) => return Ok(Async::NotReady),

                Err(e) => {
                    match e.kind() {
                        ErrorKind::BrokenPipe | ErrorKind::Interrupted => continue,
                        _ => {
                            println!("IpcServer: endpoint connection error {:?}", e);
                            return Err(());
                        }
                    }
                } 
            }
        }
    }
}

fn main() {
    tokio::run(IpcServer::new());
}
@hankbao
Copy link
Author

hankbao commented Aug 8, 2019

Ah, I figured it out.

The first time Incoming::poll being called is meant to register itself to the underlying IOCP writable event. To do that, it first needs to register the internal PollEvented2 as a mio Registration.

tokio-named-pipe relies on the mio registration taking place during NamedPipe::from_pipe. But that depends on the handle passed in being a bound tokio::reactor::Reactor handle. Otherwise, it fails silently and never gets notified again.

In the earlier version of tokio, there is a tokio::reactor::Handle::current() method to provide us a bound handle. So everything is fine at that time. But that method is deprecated in the current version. And the new tokio::reactor::Handle::default() method makes things worse by providing a lazy-bind handle which let the code compile but fail to register during NamedPipe::from_pipe at runtime. So the IpcServer hangs eventually after its first poll.

@passchaos
Copy link

@hankbao Hi,I also encountered this problem, is there any fix?

@hankbao
Copy link
Author

hankbao commented Aug 16, 2019

@hankbao Hi,I also encountered this problem, is there any fix?

I just use tokio::reactor::Handle::current() and ignore the deprecation warning for now.

onsails added a commit to onsails/jsonrpc that referenced this issue Sep 28, 2019
onsails added a commit to onsails/jsonrpc that referenced this issue Sep 29, 2019
tomusdrw pushed a commit to paritytech/jsonrpc that referenced this issue Sep 30, 2019
bors bot added a commit to crypto-com/thaler that referenced this issue Oct 9, 2019
458: Bump jsonrpc-core-client from 13.2.0 to 14.0.0 r=tomtau a=dependabot-preview[bot]

Bumps [jsonrpc-core-client](https://github.com/paritytech/jsonrpc) from 13.2.0 to 14.0.0.
<details>
<summary>Commits</summary>

- [`7b94363`](paritytech/jsonrpc@7b94363) Bump to 14.0 ([#496](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/496))
- [`3b790c6`](paritytech/jsonrpc@3b790c6) Fix threading and closing of servers ([#495](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/495))
- [`d8cfec5`](paritytech/jsonrpc@d8cfec5) Run format only on stable @ linux. ([#494](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/494))
- [`77d7fb6`](paritytech/jsonrpc@77d7fb6) fix for [#490](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/490), related to [paritytech/parity-tokio-ipc#15](https://github-redirect.dependabot.com/NikVolf/parity-tokio-ipc/issues/15) ([#491](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/491))
- See full diff in [compare view](paritytech/jsonrpc@v13.2.0...v14.0.0)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=jsonrpc-core-client&package-manager=cargo&previous-version=13.2.0&new-version=14.0.0)](https://dependabot.com/compatibility-score.html?dependency-name=jsonrpc-core-client&package-manager=cargo&previous-version=13.2.0&new-version=14.0.0)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
bors bot added a commit to crypto-com/thaler that referenced this issue Oct 10, 2019
442: Problem: (CRO-145) no HD-wallet support r=tomtau a=leejw51crypto

Solution: add bip 39, 44 cargo, and modify to use it


connect hdwallet


connect basic key service


choose hdkey


hd wallet works


add mnemonics functions


add wallet kind in constructing wallet


hdwallet & mnemonics works


decouple wallet kind to setup first


client-cli now works


refactoring


process basic wallet


hide logs


tidy up


fix clippy issues


fix clippy issue



460: Bump jsonrpc-derive from 13.2.0 to 14.0.0 r=tomtau a=dependabot-preview[bot]

Bumps [jsonrpc-derive](https://github.com/paritytech/jsonrpc) from 13.2.0 to 14.0.0.
<details>
<summary>Commits</summary>

- [`7b94363`](paritytech/jsonrpc@7b94363) Bump to 14.0 ([#496](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/496))
- [`3b790c6`](paritytech/jsonrpc@3b790c6) Fix threading and closing of servers ([#495](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/495))
- [`d8cfec5`](paritytech/jsonrpc@d8cfec5) Run format only on stable @ linux. ([#494](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/494))
- [`77d7fb6`](paritytech/jsonrpc@77d7fb6) fix for [#490](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/490), related to [paritytech/parity-tokio-ipc#15](https://github-redirect.dependabot.com/NikVolf/parity-tokio-ipc/issues/15) ([#491](https://github-redirect.dependabot.com/paritytech/jsonrpc/issues/491))
- See full diff in [compare view](paritytech/jsonrpc@v13.2.0...v14.0.0)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=jsonrpc-derive&package-manager=cargo&previous-version=13.2.0&new-version=14.0.0)](https://dependabot.com/compatibility-score.html?dependency-name=jsonrpc-derive&package-manager=cargo&previous-version=13.2.0&new-version=14.0.0)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

463: Problem: (CRO-452) Byzantine validators are not jailed r=tomtau a=devashishdxt

Solution: Jail byzantine validators in begin block

Co-authored-by: Jongwhan Lee <jonghwan@crypto.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Devashish Dixit <devashish@crypto.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants