minato_overdue (minato v1.2.0)
View SourceEnds a write that ran out of time, for the one transport that cannot.
A TLS session over the socket transport is written by ssl, and ssl:send/2
takes no deadline: it waits for the peer for as long as the peer cares to stop
reading, with the caller waiting inside it. Nothing the caller holds can end
that, because the caller is the one that is blocked.
So the caller starts a timer before the write and cancels it after, and this
process is where the timer is addressed. It hears only of a write that ran
out, and shuts the socket under the session down in both directions, which is
what makes ssl give the writer an answer. Shutting down, not closing: a
socket is closed by its owner, which is ssl, and can be shut down by
anyone holding it.
A write that finishes in time costs its timer and nothing here. There is one of
these for the node, started by minato_sup.
Without the application
A connection can be opened with minato_conn:connect/1 on a node where the
minato application was never started, or has been stopped, and then nobody
is registered here for a timer to be addressed to. The deadline holds there as
well: the write is given a process of its own to end it, which lives until the
write comes back or the writer dies. That is a process started per write
where the application would have cost a timer, so start the application.
The name
minato_overdue is this process's registered name and its child id under
minato_sup, and minato_sup is the supervisor's. Neither can be the name
of a pool or a listener: minato:start_pool/2 and minato:start_listener/2
answer {error, {reserved_name, Name}}, and minato:stop_pool/1 answers
{error, not_found} rather than stopping what bounds every TLS write.
Summary
Functions
The write came back in time.
Whether the write that just failed is one that was ended for running out.
Start the process the timers are addressed to.
Give a write on the session over Socket this long, starting now.
Types
-opaque watch()
A write being timed, from watch/2.
Functions
-spec finished(watch()) -> ok.
The write came back in time.
Whether the write that just failed is one that was ended for running out.
-spec start_link() -> gen_server:start_ret().
Start the process the timers are addressed to.
-spec watch(minato_socket:socket(), non_neg_integer()) -> watch().
Give a write on the session over Socket this long, starting now.