diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lager_exchange_backend.erl | 4 | ||||
| -rw-r--r-- | src/lqueue.erl | 2 | ||||
| -rw-r--r-- | src/rabbit.erl | 12 | ||||
| -rw-r--r-- | src/rabbit_config.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_health_check.erl | 31 | ||||
| -rw-r--r-- | src/rabbit_mirror_queue_master.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_mirror_queue_misc.erl | 3 | ||||
| -rw-r--r-- | src/rabbit_mirror_queue_sync.erl | 1 | ||||
| -rw-r--r-- | src/rabbit_networking.erl | 7 | ||||
| -rw-r--r-- | src/rabbit_plugins.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_prequeue.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_reader.erl | 7 | ||||
| -rw-r--r-- | src/rabbit_sysmon_handler.erl | 2 |
13 files changed, 50 insertions, 34 deletions
diff --git a/src/lager_exchange_backend.erl b/src/lager_exchange_backend.erl index cbff53aaa3..6e492f649d 100644 --- a/src/lager_exchange_backend.erl +++ b/src/lager_exchange_backend.erl @@ -39,8 +39,8 @@ -record(state, {level :: {'mask', integer()}, formatter :: atom(), format_config :: any(), - init_exchange_ts = undefined :: rabbit_types:timestamp(), - exchange = undefined :: #resource{}}). + init_exchange_ts = undefined :: integer() | undefined, + exchange = undefined :: #resource{} | undefined}). -ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). diff --git a/src/lqueue.erl b/src/lqueue.erl index 820f9f4a2f..cb5e0a3a9c 100644 --- a/src/lqueue.erl +++ b/src/lqueue.erl @@ -30,7 +30,7 @@ ?MODULE/1 ]). --opaque ?MODULE() :: {non_neg_integer(), queue:queue(term())}. +-opaque ?MODULE() :: ?MODULE(_). -opaque ?MODULE(T) :: {non_neg_integer(), queue:queue(T)}. -type value() :: any(). -type result(T) :: 'empty' | {'value', T}. diff --git a/src/rabbit.erl b/src/rabbit.erl index febc4b2744..222b6cf3c0 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -314,14 +314,10 @@ ensure_config() -> log_boot_error_and_exit(check_config_file, ErrFmt, ErrArgs) end, case rabbit_config:prepare_and_use_config() of - {error, Reason} -> - {Format, Arg} = case Reason of - {generation_error, Error} -> {"~s", [Error]}; - Other -> {"~p", [Other]} - end, + {error, {generation_error, Error}} -> log_boot_error_and_exit(generate_config_file, - "~nConfig file generation failed "++Format, - Arg); + "~nConfig file generation failed ~s", + Error); ok -> ok end. @@ -688,6 +684,7 @@ stop_apps(Apps) -> end, ok. +-spec handle_app_error(_) -> fun((_, _) -> no_return()). handle_app_error(Term) -> fun(App, {bad_return, {_MFA, {'EXIT', ExitReason}}}) -> throw({Term, App, ExitReason}); @@ -1006,6 +1003,7 @@ boot_error(Class, Reason) -> [lager:pr_stacktrace(erlang:get_stacktrace(), {Class, Reason})] ++ LogLocations). +-spec log_boot_error_and_exit(_, _, _) -> no_return(). log_boot_error_and_exit(Reason, Format, Args) -> rabbit_log:error(Format, Args), io:format(standard_error, "~nBOOT FAILED~n===========~n" ++ Format ++ "~n", Args), diff --git a/src/rabbit_config.erl b/src/rabbit_config.erl index a18e3888c5..a98f8bc046 100644 --- a/src/rabbit_config.erl +++ b/src/rabbit_config.erl @@ -121,9 +121,7 @@ maybe_set_net_ticktime(KernelConfig) -> io:format(standard_error, "~nCouldn't set net_ticktime to ~p " "as net_kernel is busy changing net_ticktime to ~p seconds ~n", - [NetTickTime, NewNetTicktime]); - _ -> - ok + [NetTickTime, NewNetTicktime]) end end. diff --git a/src/rabbit_health_check.erl b/src/rabbit_health_check.erl index 97d8d44dc3..d6e9756c62 100644 --- a/src/rabbit_health_check.erl +++ b/src/rabbit_health_check.erl @@ -51,14 +51,15 @@ run_checks([C|Cs]) -> Error end. +%% A lot of health checks seem to not be able to fail anymore. node_health_check(list_channels) -> case rabbit_channel:info_local([pid]) of L when is_list(L) -> - ok; - Other -> - ErrorMsg = io_lib:format("list_channels unexpected output: ~p", - [Other]), - {error_string, ErrorMsg} + ok%; +% Other -> +% ErrorMsg = io_lib:format("list_channels unexpected output: ~p", +% [Other]), +% {error_string, ErrorMsg} end; node_health_check(list_queues) -> @@ -67,11 +68,11 @@ node_health_check(list_queues) -> node_health_check(rabbit_node_monitor) -> case rabbit_node_monitor:partitions() of L when is_list(L) -> - ok; - Other -> - ErrorMsg = io_lib:format("rabbit_node_monitor reports unexpected partitions value: ~p", - [Other]), - {error_string, ErrorMsg} + ok%; +% Other -> +% ErrorMsg = io_lib:format("rabbit_node_monitor reports unexpected partitions value: ~p", +% [Other]), +% {error_string, ErrorMsg} end; node_health_check(alarms) -> @@ -88,9 +89,9 @@ health_check_queues([]) -> health_check_queues([VHost|RestVHosts]) -> case rabbit_amqqueue:info_local(VHost) of L when is_list(L) -> - health_check_queues(RestVHosts); - Other -> - ErrorMsg = io_lib:format("list_queues unexpected output for vhost ~s: ~p", - [VHost, Other]), - {error_string, ErrorMsg} + health_check_queues(RestVHosts)%; +% Other -> +% ErrorMsg = io_lib:format("list_queues unexpected output for vhost ~s: ~p", +% [VHost, Other]), +% {error_string, ErrorMsg} end. diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl index 6ab9a875c2..a403d68a74 100644 --- a/src/rabbit_mirror_queue_master.erl +++ b/src/rabbit_mirror_queue_master.erl @@ -70,15 +70,18 @@ %% Backing queue %% --------------------------------------------------------------------------- +-spec start(_, _) -> no_return(). start(_Vhost, _DurableQueues) -> %% This will never get called as this module will never be %% installed as the default BQ implementation. exit({not_valid_for_generic_backing_queue, ?MODULE}). +-spec stop(_) -> no_return(). stop(_Vhost) -> %% Same as start/1. exit({not_valid_for_generic_backing_queue, ?MODULE}). +-spec delete_crashed(_) -> no_return(). delete_crashed(_QName) -> exit({not_valid_for_generic_backing_queue, ?MODULE}). @@ -228,6 +231,7 @@ purge(State = #state { gm = GM, {Count, BQS1} = BQ:purge(BQS), {Count, State #state { backing_queue_state = BQS1 }}. +-spec purge_acks(_) -> no_return(). purge_acks(_State) -> exit({not_implemented, {?MODULE, purge_acks}}). publish(Msg = #basic_message { id = MsgId }, MsgProps, IsDelivered, ChPid, Flow, diff --git a/src/rabbit_mirror_queue_misc.erl b/src/rabbit_mirror_queue_misc.erl index 88aef8fcdc..04ed4e2887 100644 --- a/src/rabbit_mirror_queue_misc.erl +++ b/src/rabbit_mirror_queue_misc.erl @@ -61,7 +61,8 @@ -spec remove_from_queue (rabbit_amqqueue:name(), pid(), [pid()]) -> - {'ok', pid(), [pid()], [node()]} | {'error', 'not_found'}. + {'ok', pid(), [pid()], [node()]} | {'error', 'not_found'} | + {'error', {'not_synced', [pid()]}}. remove_from_queue(QueueName, Self, DeadGMPids) -> rabbit_misc:execute_mnesia_transaction( diff --git a/src/rabbit_mirror_queue_sync.erl b/src/rabbit_mirror_queue_sync.erl index 2d7ce7edb2..84ab849572 100644 --- a/src/rabbit_mirror_queue_sync.erl +++ b/src/rabbit_mirror_queue_sync.erl @@ -78,6 +78,7 @@ master_prepare(Ref, QName, Log, SPids) -> non_neg_integer(), bq(), bqs()) -> {'already_synced', bqs()} | {'ok', bqs()} | + {'cancelled', bqs()} | {'shutdown', any(), bqs()} | {'sync_died', any(), bqs()}. diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl index 809b999b98..5fb42028b0 100644 --- a/src/rabbit_networking.erl +++ b/src/rabbit_networking.erl @@ -177,7 +177,7 @@ tcp_listener_addresses_auto(Port) -> -spec tcp_listener_spec (name_prefix(), address(), [gen_tcp:listen_option()], module(), module(), - protocol(), any(), non_neg_integer(), label()) -> + any(), protocol(), non_neg_integer(), label()) -> supervisor:child_spec(). tcp_listener_spec(NamePrefix, {IPAddress, Port, Family}, SocketOpts, @@ -285,6 +285,10 @@ tcp_listener_stopped(Protocol, Opts, IPAddress, Port) -> port = Port, opts = Opts}). +%% @todo Temporary, to be removed before merge. Real fix is +%% in an OTP PR at https://github.com/erlang/otp/pull/2117 +-dialyzer({nowarn_function, record_distribution_listener/0}). + record_distribution_listener() -> {Name, Host} = rabbit_nodes:parts(node()), {port, Port, _Version} = erl_epmd:port_please(Name, Host), @@ -449,6 +453,7 @@ gethostaddr(Host, Family) -> {error, Reason} -> host_lookup_error(Host, Reason) end. +-spec host_lookup_error(_, _) -> no_return(). host_lookup_error(Host, Reason) -> rabbit_log:error("invalid host ~p - ~p~n", [Host, Reason]), throw({error, {invalid_host, Host, Reason}}). diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index 6adce8a24e..abb62a4f9d 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -310,7 +310,7 @@ is_loadable(App) -> %% List running plugins along with their version. --spec running_plugins() -> [{atom(), Vsn :: string()}]. +-spec running_plugins() -> {ok, [{atom(), Vsn :: string()}]}. running_plugins() -> ActivePlugins = active(), {ok, [{App, Vsn} || {App, _ , Vsn} <- rabbit_misc:which_applications(), lists:member(App, ActivePlugins)]}. diff --git a/src/rabbit_prequeue.erl b/src/rabbit_prequeue.erl index 5e92013424..0b4b9984f9 100644 --- a/src/rabbit_prequeue.erl +++ b/src/rabbit_prequeue.erl @@ -97,8 +97,13 @@ crash_restart(Q0) when ?is_amqqueue(Q0) -> %% This gen_server2 always hands over to some other module at the end %% of init/1. +-spec handle_call(_, _, _) -> no_return(). handle_call(_Msg, _From, _State) -> exit(unreachable). +-spec handle_cast(_, _) -> no_return(). handle_cast(_Msg, _State) -> exit(unreachable). +-spec handle_info(_, _) -> no_return(). handle_info(_Msg, _State) -> exit(unreachable). +-spec terminate(_, _) -> no_return(). terminate(_Reason, _State) -> exit(unreachable). +-spec code_change(_, _, _) -> no_return(). code_change(_OldVsn, _State, _Extra) -> exit(unreachable). diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index 95a6b185c2..dd882a0856 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -191,7 +191,7 @@ init(Parent, HelperSup, Ref) -> system_continue(Parent, Deb, {Buf, BufLen, State}) -> mainloop(Deb, Buf, BufLen, State#v1{parent = Parent}). --spec system_terminate(_,_,_,_) -> none(). +-spec system_terminate(_,_,_,_) -> no_return(). system_terminate(Reason, _Parent, _Deb, _State) -> exit(Reason). @@ -462,7 +462,7 @@ log_connection_exception(Severity, Name, Ex) -> log_connection_exception_with_severity(Severity, Fmt, Args) -> case Severity of debug -> rabbit_log_connection:debug(Fmt, Args); - info -> rabbit_log_connection:info(Fmt, Args); +% info -> rabbit_log_connection:info(Fmt, Args); warning -> rabbit_log_connection:warning(Fmt, Args); error -> rabbit_log_connection:error(Fmt, Args) end. @@ -552,6 +552,7 @@ mainloop(Deb, Buf, BufLen, State = #v1{sock = Sock, end end. +-spec stop(_, #v1{}) -> no_return(). stop(tcp_healthcheck, State) -> %% The connection was closed before any packet was received. It's %% probably a load-balancer healthcheck: don't consider this a @@ -872,6 +873,7 @@ handle_exception(State, Channel, Reason) -> %% we've "lost sync" with the client and hence must not accept any %% more input +-spec fatal_frame_error(_, _, _, _, _) -> no_return(). fatal_frame_error(Error, Type, Channel, Payload, State) -> frame_error(Error, Type, Channel, Payload, State), %% grace period to allow transmission of error @@ -1110,6 +1112,7 @@ start_connection({ProtocolMajor, ProtocolMinor, _ProtocolRevision}, connection_state = starting}, frame_header, 7). +-spec refuse_connection(_, _, _) -> no_return(). refuse_connection(Sock, Exception, {A, B, C, D}) -> ok = inet_op(fun () -> rabbit_net:send(Sock, <<"AMQP",A,B,C,D>>) end), throw(Exception). diff --git a/src/rabbit_sysmon_handler.erl b/src/rabbit_sysmon_handler.erl index a4759b2e16..f4b286f032 100644 --- a/src/rabbit_sysmon_handler.erl +++ b/src/rabbit_sysmon_handler.erl @@ -32,7 +32,7 @@ -export([init/1, handle_event/2, handle_call/2, handle_info/2, terminate/2, code_change/3]). --record(state, {timer_ref :: reference()}). +-record(state, {timer_ref :: reference() | undefined}). -define(INACTIVITY_TIMEOUT, 5000). |
