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

It is not possible to recreate a listener with the same uri and a different protocol #1810

Open
IvanEsyagin-iss opened this issue Nov 6, 2024 · 0 comments

Comments

@IvanEsyagin-iss
Copy link

The scenario:

  1. Create and open two listeners on different ports with the http protocol.
  2. Close and delete one of them.
  3. Re-create and open the same listener, but with https protocol.

The result:
An exception is thrown std::invalid_argument with the message : "Error: http_listener can not simultaneously listen both http and https paths of one host". But if initially there were not two listeners but one, then everything would work correctly.

The analysis:
http_linux_server has a map std::map<std::string, std::unique_ptr<hostport_listener>, iequal_to> m_listeners, where new hostport_listener are added with the host+port key in the pplx::task http_server_api::register_listener() function. But there is no deletion from this map in the pplx::task http_linux_server::unregister_listener() function. Therefore, until http_linux_server is deleted(that is, we will not close all open listener) the map will contain an hostport_listener that has already been created. And since the protocol can only be set in the constructor, there is no way to change it.

Here I offered my solution.

I have attached a file with an example example.txt.

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

1 participant