diff options
Diffstat (limited to 'src/ranch_server.erl')
-rw-r--r-- | src/ranch_server.erl | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ranch_server.erl b/src/ranch_server.erl index b0ae612..078626f 100644 --- a/src/ranch_server.erl +++ b/src/ranch_server.erl @@ -20,6 +20,8 @@ -export([start_link/0]). -export([insert_listener/2]). -export([lookup_listener/1]). +-export([set_connections_sup/2]). +-export([lookup_connections_sup/1]). -export([add_acceptor/2]). -export([send_to_acceptors/2]). -export([add_connection/1]). @@ -52,7 +54,7 @@ start_link() -> %% @doc Insert a listener into the database. -spec insert_listener(any(), pid()) -> ok. insert_listener(Ref, Pid) -> - true = ets:insert_new(?TAB, {{listener, Ref}, Pid}), + true = ets:insert_new(?TAB, {{listener, Ref}, Pid, undefined}), gen_server:cast(?MODULE, {insert_listener, Ref, Pid}). %% @doc Lookup a listener in the database. @@ -60,6 +62,17 @@ insert_listener(Ref, Pid) -> lookup_listener(Ref) -> ets:lookup_element(?TAB, {listener, Ref}, 2). +%% @doc Set a connection supervisor associated with specific listener. +-spec set_connections_sup(any(), pid()) -> ok. +set_connections_sup(Ref, Pid) -> + true = ets:update_element(?TAB, {listener, Ref}, {3, Pid}), + ok. + +%% @doc Lookup a connection supervisor used by specific listener. +-spec lookup_connections_sup(any()) -> pid() | undefined. +lookup_connections_sup(Ref) -> + ets:lookup_element(?TAB, {listener, Ref}, 3). + %% @doc Add an acceptor for the given listener. -spec add_acceptor(any(), pid()) -> ok. add_acceptor(Ref, Pid) -> |