diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2010-08-17 13:54:03 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-08-17 13:54:03 +0100 |
commit | 73f9b32cce3c81409fa41a810b2dc316a426a042 (patch) | |
tree | e346322457eb7deae44bf82b669d30e979667f8a /src/tcp_acceptor.erl | |
parent | 64d7eebf985987a10eaeaef3f8e8111b1f9cd5bf (diff) | |
download | rabbitmq-server-73f9b32cce3c81409fa41a810b2dc316a426a042.tar.gz |
Combine obtains and release_on_death
Diffstat (limited to 'src/tcp_acceptor.erl')
-rw-r--r-- | src/tcp_acceptor.erl | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tcp_acceptor.erl b/src/tcp_acceptor.erl index cc4982c9..88fd2fd4 100644 --- a/src/tcp_acceptor.erl +++ b/src/tcp_acceptor.erl @@ -43,11 +43,12 @@ %%-------------------------------------------------------------------- start_link(Callback, LSock) -> - gen_server:start_link(?MODULE, {Callback, LSock}, []). + gen_server:start_link(?MODULE, {Callback, LSock}, [{timeout, infinity}]). %%-------------------------------------------------------------------- init({Callback, LSock}) -> + ok = file_handle_cache:obtain_and_release_on_death(self()), gen_server:cast(self(), accept), {ok, #state{callback=Callback, sock=LSock}}. @@ -83,7 +84,7 @@ handle_info({inet_async, LSock, Ref, {ok, Sock}}, %% is drained. gen_event:which_handlers(error_logger), %% handle - file_handle_cache:release_on_death(apply(M, F, A ++ [Sock])) + file_handle_cache:obtain_and_release_on_death(apply(M, F, A ++ [Sock])) catch {inet_error, Reason} -> gen_tcp:close(Sock), error_logger:error_msg("unable to accept TCP connection: ~p~n", @@ -111,7 +112,6 @@ code_change(_OldVsn, State, _Extra) -> inet_op(F) -> rabbit_misc:throw_on_error(inet_error, F). accept(State = #state{sock=LSock}) -> - ok = file_handle_cache:obtain(), case prim_inet:async_accept(LSock, -1) of {ok, Ref} -> {noreply, State#state{ref=Ref}}; Error -> {stop, {cannot_accept, Error}, State} |