h1_listener (h1 v0.8.0)

View Source

HTTP/1.1 listener: owns the listen socket, supervises the acceptor pool, and tracks every accepted connection. Runs under h1_sup so the listener outlives the process that called h1:start_server/2.

Acceptors register each accepted connection-loop process ({h1_conn_started, Pid}); the loop registers its h1_connection once it is up ({h1_conn_up, LoopPid, ConnPid}). stop/2 is synchronous: it stops accepting, then closes every tracked connection before returning. stop_accepting/2 only closes the listen socket and acceptor pool, leaving established connections to finish (graceful drain).

Summary

Functions

Synchronously stop the listener: close the listen socket, the acceptor pool, and every accepted connection. Returns once all of them are closed (or if the listener is already gone).

Synchronously stop accepting new connections while leaving the established ones running. The listener stays alive to track them; a later stop/2 closes them.

Types

args/0

-type args() ::
          #{transport := transport(),
            listen_socket := term(),
            acceptor_count := pos_integer(),
            ref := reference(),
            handler := term(),
            conn_opts := map(),
            server_opts := map()}.

transport/0

-type transport() :: gen_tcp | ssl.

Functions

init(Parent, Args)

start_link(Args)

-spec start_link(args()) -> {ok, pid()}.

stop(Pid, Ref)

-spec stop(pid(), reference()) -> ok.

Synchronously stop the listener: close the listen socket, the acceptor pool, and every accepted connection. Returns once all of them are closed (or if the listener is already gone).

stop_accepting(Pid, Ref)

-spec stop_accepting(pid(), reference()) -> ok.

Synchronously stop accepting new connections while leaving the established ones running. The listener stays alive to track them; a later stop/2 closes them.