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

How to cancel an idle connection #121

Closed
dignifiedquire opened this issue May 5, 2019 · 6 comments
Closed

How to cancel an idle connection #121

dignifiedquire opened this issue May 5, 2019 · 6 comments

Comments

@dignifiedquire
Copy link
Contributor

I need to support the following API

  • on one thread a connection is made, and switched to idle using wait
  • when shutting down gracefully, another thread needs to send a signal to interrupt the idle and shutting down the connection.

Is this possible with the current api and I am missing something, or is there something that needs to be added?

@jonhoo
Copy link
Owner

jonhoo commented May 6, 2019

Hmm, that's a little tricky to do, but I think it may be possible. Specifically, if you are on a Unix system, you should be able to establish the connection yourself first (using std::net:TcpStream::connect), get another handle to the same connection with try_clone, create an imap::Client from the first handle with new, and then terminate the connection using that second handle from the other thread when appropriate.

@dignifiedquire
Copy link
Contributor Author

Thanks, started looking into this, and it almost works, but read_greeting is private currently, so I can't fully establish the connection. Any chance that could be switched to be public?

@jonhoo
Copy link
Owner

jonhoo commented May 10, 2019

Hmm, why do you need read_greeting to be public? Is Client::login not sufficient?

@dignifiedquire
Copy link
Contributor Author

dignifiedquire commented May 10, 2019 via email

@jonhoo
Copy link
Owner

jonhoo commented May 10, 2019

You should be able to do Client::new(stream).login though, no?

@dignifiedquire
Copy link
Contributor Author

yes that works 👌

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