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

accept_stream hangs when connection dies #118

Closed
klacke opened this issue Sep 28, 2022 · 1 comment · Fixed by #131
Closed

accept_stream hangs when connection dies #118

klacke opened this issue Sep 28, 2022 · 1 comment · Fixed by #131
Assignees
Labels
enhancement New feature or request

Comments

@klacke
Copy link
Contributor

klacke commented Sep 28, 2022

If client end dies, accept_stream hangs with a {quic, closed, Conn} message in the message queue.
A possible fix is:

accept_stream(Conn, Opts, Timeout) when is_list(Opts) ->
  accept_stream(Conn, maps:from_list(Opts), Timeout);
accept_stream(Conn, Opts, Timeout) when is_map(Opts) ->
  % @todo make_ref
  % @todo error handling
  NewOpts = maps:merge(default_stream_opts(), Opts),
  case quicer_nif:async_accept_stream(Conn, NewOpts) of
    {ok, Conn} ->
      receive
        {quic, new_stream, Stream} ->
          {ok, Stream};
        {quic, closed, Conn} ->
          {error, connection_closed}

      after Timeout ->
          {error, timeout}
      end;
    {error, _} = E ->
      E
  end.
@qzhuyan
Copy link
Collaborator

qzhuyan commented Sep 28, 2022

thanks for reporting.

Your solution will help if caller process is the owner of both connection and the stream so it will recv 'events' from both connection and stream.

I think we need a signal to inform the stream acceptor that the connection is closed in resource dtor.

something like the todo in https://github.com/emqx/quic/blob/main/c_src/quicer_nif.c#L639

@qzhuyan qzhuyan added the enhancement New feature or request label Sep 30, 2022
@qzhuyan qzhuyan self-assigned this Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants