diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2010-11-11 15:34:09 +0000 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-11-11 15:34:09 +0000 |
| commit | c22130dfc267e8e4aa05bdd630386fd838ccb4be (patch) | |
| tree | b51599201b445beea6573c47f296c455a09b9b7f | |
| parent | 25e0e894ae1ce67b59b082f1bed4d4450eccff21 (diff) | |
| parent | 5894e354d772d2812c5f4d8fac6fb071067e0831 (diff) | |
| download | rabbitmq-server-git-c22130dfc267e8e4aa05bdd630386fd838ccb4be.tar.gz | |
Merging bug 22614 into default
| -rw-r--r-- | Makefile | 18 | ||||
| -rw-r--r-- | codegen.py | 21 | ||||
| -rw-r--r-- | src/gen_server2.erl | 27 | ||||
| -rw-r--r-- | src/rabbit_access_control.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_amqqueue.erl | 18 | ||||
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 17 | ||||
| -rw-r--r-- | src/rabbit_binary_generator.erl | 7 | ||||
| -rw-r--r-- | src/rabbit_binding.erl | 20 | ||||
| -rw-r--r-- | src/rabbit_channel.erl | 12 | ||||
| -rw-r--r-- | src/rabbit_dialyzer.erl | 92 | ||||
| -rw-r--r-- | src/rabbit_exchange.erl | 14 | ||||
| -rw-r--r-- | src/rabbit_framing.erl | 64 | ||||
| -rw-r--r-- | src/rabbit_invariable_queue.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_memory_monitor.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_misc.erl | 41 | ||||
| -rw-r--r-- | src/rabbit_msg_store.erl | 6 | ||||
| -rw-r--r-- | src/rabbit_networking.erl | 14 | ||||
| -rw-r--r-- | src/rabbit_queue_index.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_reader.erl | 14 | ||||
| -rw-r--r-- | src/rabbit_ssl.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_types.erl | 8 | ||||
| -rw-r--r-- | src/rabbit_variable_queue.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_writer.erl | 5 | ||||
| -rw-r--r-- | src/supervisor2.erl | 3 |
24 files changed, 200 insertions, 220 deletions
@@ -111,27 +111,23 @@ $(SOURCE_DIR)/rabbit_framing_amqp_0_8.erl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_c $(PYTHON) codegen.py body $(AMQP_SPEC_JSON_FILES_0_8) $@ dialyze: $(BEAM_TARGETS) $(BASIC_PLT) - $(ERL_EBIN) -eval \ - "rabbit_dialyzer:dialyze_files(\"$(BASIC_PLT)\", \"$(BEAM_TARGETS)\")." \ - -eval \ - "init:stop()." - - + dialyzer --plt $(BASIC_PLT) --no_native \ + -Wrace_conditions $(BEAM_TARGETS) # rabbit.plt is used by rabbitmq-erlang-client's dialyze make target create-plt: $(RABBIT_PLT) $(RABBIT_PLT): $(BEAM_TARGETS) $(BASIC_PLT) - cp $(BASIC_PLT) $@ - $(ERL_EBIN) -eval \ - "rabbit_dialyzer:halt_with_code(rabbit_dialyzer:add_to_plt(\"$@\", \"$(BEAM_TARGETS)\"))." + dialyzer --plt $(BASIC_PLT) --output_plt $@ --no_native \ + --add_to_plt $(BEAM_TARGETS) $(BASIC_PLT): $(BEAM_TARGETS) if [ -f $@ ]; then \ touch $@; \ else \ - $(ERL_EBIN) -eval \ - "rabbit_dialyzer:halt_with_code(rabbit_dialyzer:create_basic_plt(\"$@\"))."; \ + dialyzer --output_plt $@ --build_plt \ + --apps erts kernel stdlib compiler sasl os_mon mnesia tools \ + public_key crypto ssl; \ fi clean: diff --git a/codegen.py b/codegen.py index 4fdbec554f..979c5bd82d 100644 --- a/codegen.py +++ b/codegen.py @@ -240,8 +240,6 @@ def genErl(spec): elif type == 'table': print " F%d = rabbit_binary_parser:parse_table(F%dTab)," % \ (f.index, f.index) - elif type == 'shortstr': - print " if F%dLen > 255 -> exit(method_field_shortstr_overflow); true -> ok end," % (f.index) else: pass @@ -278,8 +276,7 @@ def genErl(spec): print " F%dTab = rabbit_binary_generator:generate_table(F%d)," % (f.index, f.index) print " F%dLen = size(F%dTab)," % (f.index, f.index) elif type == 'shortstr': - print " F%dLen = size(F%d)," % (f.index, f.index) - print " if F%dLen > 255 -> exit(method_field_shortstr_overflow); true -> ok end," % (f.index) + print " F%dLen = shortstr_size(F%d)," % (f.index, f.index) elif type == 'longstr': print " F%dLen = size(F%d)," % (f.index, f.index) else: @@ -348,9 +345,11 @@ def genErl(spec): print "%% Various types" print "-ifdef(use_specs)." - print """-export_type([amqp_table/0, amqp_property_type/0, amqp_method_record/0, - amqp_method_name/0, amqp_method/0, amqp_class_id/0, - amqp_value/0, amqp_array/0, amqp_exception/0, amqp_property_record/0]). + print """-export_type([amqp_field_type/0, amqp_property_type/0, + amqp_table/0, amqp_array/0, amqp_value/0, + amqp_method_name/0, amqp_method/0, amqp_method_record/0, + amqp_method_field_name/0, amqp_property_record/0, + amqp_exception/0, amqp_exception_code/0, amqp_class_id/0]). -type(amqp_field_type() :: 'longstr' | 'signedint' | 'decimal' | 'timestamp' | @@ -418,7 +417,7 @@ def genErl(spec): (amqp_method_name(), binary()) -> amqp_method_record() | rabbit_types:connection_exit()). -spec(decode_properties/2 :: (non_neg_integer(), binary()) -> amqp_property_record()). -spec(encode_method_fields/1 :: (amqp_method_record()) -> binary()). --spec(encode_properties/1 :: (amqp_method_record()) -> binary()). +-spec(encode_properties/1 :: (amqp_property_record()) -> binary()). -spec(lookup_amqp_exception/1 :: (amqp_exception()) -> {boolean(), amqp_exception_code(), binary()}). -spec(amqp_exception/1 :: (amqp_exception_code()) -> amqp_exception()). -endif. % use_specs @@ -426,6 +425,12 @@ def genErl(spec): bitvalue(true) -> 1; bitvalue(false) -> 0; bitvalue(undefined) -> 0. + +shortstr_size(S) -> + case size(S) of + Len when Len =< 255 -> Len; + _ -> exit(method_field_shortstr_overflow) + end. """ version = "{%d, %d, %d}" % (spec.major, spec.minor, spec.revision) if version == '{8, 0, 0}': version = '{0, 8, 0}' diff --git a/src/gen_server2.erl b/src/gen_server2.erl index 230d1f2aa1..6e02b23ecb 100644 --- a/src/gen_server2.erl +++ b/src/gen_server2.erl @@ -177,7 +177,7 @@ format_status/2]). %% Internal exports --export([init_it/6, print_event/3]). +-export([init_it/6]). -import(error_logger, [format/2]). @@ -192,10 +192,13 @@ -ifdef(use_specs). --spec(handle_common_termination/3 :: - (any(), atom(), #gs2_state{}) -> no_return()). +-type(gs2_state() :: #gs2_state{}). --spec(hibernate/1 :: (#gs2_state{}) -> no_return()). +-spec(handle_common_termination/3 :: + (any(), atom(), gs2_state()) -> no_return()). +-spec(hibernate/1 :: (gs2_state()) -> no_return()). +-spec(pre_hibernate/1 :: (gs2_state()) -> no_return()). +-spec(system_terminate/4 :: (_, _, _, gs2_state()) -> no_return()). -endif. @@ -612,7 +615,7 @@ process_msg(Msg, _Msg when Debug =:= [] -> handle_msg(Msg, GS2State); _Msg -> - Debug1 = sys:handle_debug(Debug, {?MODULE, print_event}, + Debug1 = sys:handle_debug(Debug, fun print_event/3, Name, {in, Msg}), handle_msg(Msg, GS2State #gs2_state { debug = Debug1 }) end. @@ -838,13 +841,13 @@ handle_msg({'$gen_call', From, Msg}, GS2State = #gs2_state { mod = Mod, time = Time1, debug = Debug1}); {noreply, NState} -> - Debug1 = common_debug(Debug, {?MODULE, print_event}, Name, + Debug1 = common_debug(Debug, fun print_event/3, Name, {noreply, NState}), loop(GS2State #gs2_state {state = NState, time = infinity, debug = Debug1}); {noreply, NState, Time1} -> - Debug1 = common_debug(Debug, {?MODULE, print_event}, Name, + Debug1 = common_debug(Debug, fun print_event/3, Name, {noreply, NState}), loop(GS2State #gs2_state {state = NState, time = Time1, @@ -866,13 +869,13 @@ handle_common_reply(Reply, Msg, GS2State = #gs2_state { name = Name, debug = Debug}) -> case Reply of {noreply, NState} -> - Debug1 = common_debug(Debug, {?MODULE, print_event}, Name, + Debug1 = common_debug(Debug, fun print_event/3, Name, {noreply, NState}), loop(GS2State #gs2_state { state = NState, time = infinity, debug = Debug1 }); {noreply, NState, Time1} -> - Debug1 = common_debug(Debug, {?MODULE, print_event}, Name, + Debug1 = common_debug(Debug, fun print_event/3, Name, {noreply, NState}), loop(GS2State #gs2_state { state = NState, time = Time1, @@ -894,7 +897,7 @@ handle_common_termination(Reply, Msg, GS2State) -> reply(Name, {To, Tag}, Reply, State, Debug) -> reply({To, Tag}, Reply), sys:handle_debug( - Debug, {?MODULE, print_event}, Name, {out, Reply, To, State}). + Debug, fun print_event/3, Name, {out, Reply, To, State}). %%----------------------------------------------------------------- @@ -903,10 +906,6 @@ reply(Name, {To, Tag}, Reply, State, Debug) -> system_continue(Parent, Debug, GS2State) -> loop(GS2State #gs2_state { parent = Parent, debug = Debug }). --ifdef(use_specs). --spec system_terminate(_, _, _, [_]) -> no_return(). --endif. - system_terminate(Reason, _Parent, Debug, GS2State) -> terminate(Reason, [], GS2State #gs2_state { debug = Debug }). diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl index 15897dfa39..3388e5e752 100644 --- a/src/rabbit_access_control.erl +++ b/src/rabbit_access_control.erl @@ -47,7 +47,7 @@ -ifdef(use_specs). --export_type([username/0, password/0]). +-export_type([username/0, password/0, password_hash/0]). -type(permission_atom() :: 'configure' | 'read' | 'write'). -type(username() :: binary()). @@ -75,7 +75,7 @@ -spec(change_password_hash/2 :: (username(), password_hash()) -> 'ok'). -spec(set_admin/1 :: (username()) -> 'ok'). -spec(clear_admin/1 :: (username()) -> 'ok'). --spec(list_users/0 :: () -> [username()]). +-spec(list_users/0 :: () -> [{username(), boolean()}]). -spec(lookup_user/1 :: (username()) -> rabbit_types:ok(rabbit_types:user()) | rabbit_types:error('not_found')). diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 9d78bafa95..5cdd0e3cb2 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -97,14 +97,14 @@ -spec(with_exclusive_access_or_die/3 :: (name(), pid(), qfun(A)) -> A | rabbit_types:channel_exit()). -spec(list/1 :: (rabbit_types:vhost()) -> [rabbit_types:amqqueue()]). --spec(info_keys/0 :: () -> [rabbit_types:info_key()]). --spec(info/1 :: (rabbit_types:amqqueue()) -> [rabbit_types:info()]). +-spec(info_keys/0 :: () -> rabbit_types:info_keys()). +-spec(info/1 :: (rabbit_types:amqqueue()) -> rabbit_types:infos()). -spec(info/2 :: - (rabbit_types:amqqueue(), [rabbit_types:info_key()]) - -> [rabbit_types:info()]). --spec(info_all/1 :: (rabbit_types:vhost()) -> [[rabbit_types:info()]]). --spec(info_all/2 :: (rabbit_types:vhost(), [rabbit_types:info_key()]) - -> [[rabbit_types:info()]]). + (rabbit_types:amqqueue(), rabbit_types:info_keys()) + -> rabbit_types:infos()). +-spec(info_all/1 :: (rabbit_types:vhost()) -> [rabbit_types:infos()]). +-spec(info_all/2 :: (rabbit_types:vhost(), rabbit_types:info_keys()) + -> [rabbit_types:infos()]). -spec(consumers/1 :: (rabbit_types:amqqueue()) -> [{pid(), rabbit_types:ctag(), boolean()}]). @@ -162,7 +162,7 @@ -spec(set_maximum_since_use/2 :: (pid(), non_neg_integer()) -> 'ok'). -spec(maybe_expire/1 :: (pid()) -> 'ok'). -spec(on_node_down/1 :: (node()) -> 'ok'). --spec(pseudo_queue/2 :: (binary(), pid()) -> rabbit_types:amqqueue()). +-spec(pseudo_queue/2 :: (name(), pid()) -> rabbit_types:amqqueue()). -endif. @@ -361,7 +361,7 @@ consumers(#amqqueue{ pid = QPid }) -> delegate_call(QPid, consumers, infinity). consumers_all(VHostPath) -> - lists:concat( + lists:append( map(VHostPath, fun (Q) -> [{Q#amqqueue.name, ChPid, ConsumerTag, AckRequired} || {ChPid, ConsumerTag, AckRequired} <- consumers(Q)] diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index dd97d257a8..75f285dffb 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -320,18 +320,19 @@ maybe_store_ch_record(C = #cr{consumer_count = ConsumerCount, txn = Txn, unsent_message_count = UnsentMessageCount}) -> case {sets:size(ChAckTags), ConsumerCount, UnsentMessageCount, Txn} of - {0, 0, 0, none} -> demonitor_and_erase_ch_record(C), + {0, 0, 0, none} -> ok = erase_ch_record(C), false; _ -> store_ch_record(C), true end. -demonitor_and_erase_ch_record(#cr{ch_pid = ChPid, - limiter_pid = LimiterPid, - monitor_ref = MonitorRef}) -> +erase_ch_record(#cr{ch_pid = ChPid, + limiter_pid = LimiterPid, + monitor_ref = MonitorRef}) -> ok = rabbit_limiter:unregister(LimiterPid, self()), erlang:demonitor(MonitorRef), - erase({ch, ChPid}). + erase({ch, ChPid}), + ok. all_ch_record() -> [C || {{ch, _}, C} <- get()]. @@ -519,7 +520,7 @@ handle_ch_down(DownPid, State = #q{exclusive_consumer = Holder}) -> not_found -> {ok, State}; C = #cr{ch_pid = ChPid, txn = Txn, acktags = ChAckTags} -> - demonitor_and_erase_ch_record(C), + ok = erase_ch_record(C), State1 = State#q{ exclusive_consumer = case Holder of {ChPid, _} -> none; @@ -809,7 +810,7 @@ handle_call({basic_consume, NoAck, ChPid, LimiterPid, Consumer = #consumer{tag = ConsumerTag, ack_required = not NoAck}, true = maybe_store_ch_record(C#cr{consumer_count = ConsumerCount +1, - limiter_pid = LimiterPid}), + limiter_pid = LimiterPid}), ok = case ConsumerCount of 0 -> rabbit_limiter:register(LimiterPid, self()); _ -> ok @@ -845,7 +846,7 @@ handle_call({basic_cancel, ChPid, ConsumerTag, OkMsg}, _From, reply(ok, State); C = #cr{consumer_count = ConsumerCount, limiter_pid = LimiterPid} -> - C1 = C#cr{consumer_count = ConsumerCount-1}, + C1 = C#cr{consumer_count = ConsumerCount -1}, maybe_store_ch_record( case ConsumerCount of 1 -> ok = rabbit_limiter:unregister(LimiterPid, self()), diff --git a/src/rabbit_binary_generator.erl b/src/rabbit_binary_generator.erl index 722573c769..b2997ae259 100644 --- a/src/rabbit_binary_generator.erl +++ b/src/rabbit_binary_generator.erl @@ -75,9 +75,12 @@ rabbit_types:encoded_content()). -spec(clear_encoded_content/1 :: (rabbit_types:content()) -> rabbit_types:unencoded_content()). --spec(map_exception/3 :: (non_neg_integer(), rabbit_types:amqp_error(), +-spec(map_exception/3 :: (rabbit_channel:channel_number(), + rabbit_types:amqp_error() | any(), rabbit_types:protocol()) -> - {boolean(), non_neg_integer(), rabbit_framing:amqp_method()}). + {boolean(), + rabbit_channel:channel_number(), + rabbit_framing:amqp_method_record()}). -endif. diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index 1af213c474..9d1399f7cc 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -60,7 +60,7 @@ rabbit_types:ok_or_error(rabbit_types:amqp_error()))). -type(bindings() :: [rabbit_types:binding()]). --opaque(deletions() :: dict:dictionary()). +-opaque(deletions() :: dict()). -spec(recover/0 :: () -> [rabbit_types:binding()]). -spec(exists/1 :: (rabbit_types:binding()) -> boolean() | bind_errors()). @@ -78,13 +78,13 @@ -spec(list_for_source_and_destination/2 :: (rabbit_types:binding_source(), rabbit_types:binding_destination()) -> bindings()). --spec(info_keys/0 :: () -> [rabbit_types:info_key()]). --spec(info/1 :: (rabbit_types:binding()) -> [rabbit_types:info()]). --spec(info/2 :: (rabbit_types:binding(), [rabbit_types:info_key()]) -> - [rabbit_types:info()]). --spec(info_all/1 :: (rabbit_types:vhost()) -> [[rabbit_types:info()]]). --spec(info_all/2 ::(rabbit_types:vhost(), [rabbit_types:info_key()]) - -> [[rabbit_types:info()]]). +-spec(info_keys/0 :: () -> rabbit_types:info_keys()). +-spec(info/1 :: (rabbit_types:binding()) -> rabbit_types:infos()). +-spec(info/2 :: (rabbit_types:binding(), rabbit_types:info_keys()) -> + rabbit_types:infos()). +-spec(info_all/1 :: (rabbit_types:vhost()) -> [rabbit_types:infos()]). +-spec(info_all/2 ::(rabbit_types:vhost(), rabbit_types:info_keys()) + -> [rabbit_types:infos()]). -spec(has_for_source/1 :: (rabbit_types:binding_source()) -> boolean()). -spec(remove_for_source/1 :: (rabbit_types:binding_source()) -> bindings()). -spec(remove_for_destination/1 :: @@ -94,9 +94,9 @@ -spec(process_deletions/1 :: (deletions()) -> 'ok'). -spec(combine_deletions/2 :: (deletions(), deletions()) -> deletions()). -spec(add_deletion/3 :: (rabbit_exchange:name(), - {'undefined' | rabbit_types:binding_source(), + {'undefined' | rabbit_types:exchange(), 'deleted' | 'not_deleted', - deletions()}, deletions()) -> deletions()). + bindings()}, deletions()) -> deletions()). -spec(new_deletions/0 :: () -> deletions()). -endif. diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 873268cdd9..19613a57ec 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -87,17 +87,17 @@ -spec(do/3 :: (pid(), rabbit_framing:amqp_method_record(), rabbit_types:maybe(rabbit_types:content())) -> 'ok'). -spec(shutdown/1 :: (pid()) -> 'ok'). --spec(send_command/2 :: (pid(), rabbit_framing:amqp_method()) -> 'ok'). +-spec(send_command/2 :: (pid(), rabbit_framing:amqp_method_record()) -> 'ok'). -spec(deliver/4 :: (pid(), rabbit_types:ctag(), boolean(), rabbit_amqqueue:qmsg()) -> 'ok'). -spec(flushed/2 :: (pid(), pid()) -> 'ok'). -spec(list/0 :: () -> [pid()]). --spec(info_keys/0 :: () -> [rabbit_types:info_key()]). --spec(info/1 :: (pid()) -> [rabbit_types:info()]). --spec(info/2 :: (pid(), [rabbit_types:info_key()]) -> [rabbit_types:info()]). --spec(info_all/0 :: () -> [[rabbit_types:info()]]). --spec(info_all/1 :: ([rabbit_types:info_key()]) -> [[rabbit_types:info()]]). +-spec(info_keys/0 :: () -> rabbit_types:info_keys()). +-spec(info/1 :: (pid()) -> rabbit_types:infos()). +-spec(info/2 :: (pid(), rabbit_types:info_keys()) -> rabbit_types:infos()). +-spec(info_all/0 :: () -> [rabbit_types:infos()]). +-spec(info_all/1 :: (rabbit_types:info_keys()) -> [rabbit_types:infos()]). -spec(emit_stats/1 :: (pid()) -> 'ok'). -endif. diff --git a/src/rabbit_dialyzer.erl b/src/rabbit_dialyzer.erl deleted file mode 100644 index a9806305ef..0000000000 --- a/src/rabbit_dialyzer.erl +++ /dev/null @@ -1,92 +0,0 @@ -%% The contents of this file are subject to the Mozilla Public License -%% Version 1.1 (the "License"); you may not use this file except in -%% compliance with the License. You may obtain a copy of the License at -%% http://www.mozilla.org/MPL/ -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -%% License for the specific language governing rights and limitations -%% under the License. -%% -%% The Original Code is RabbitMQ. -%% -%% The Initial Developers of the Original Code are LShift Ltd, -%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. -%% -%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, -%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd -%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial -%% Technologies LLC, and Rabbit Technologies Ltd. -%% -%% Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift -%% Ltd. Portions created by Cohesive Financial Technologies LLC are -%% Copyright (C) 2007-2010 Cohesive Financial Technologies -%% LLC. Portions created by Rabbit Technologies Ltd are Copyright -%% (C) 2007-2010 Rabbit Technologies Ltd. -%% -%% All Rights Reserved. -%% -%% Contributor(s): ______________________________________. -%% - --module(rabbit_dialyzer). - --export([create_basic_plt/1, add_to_plt/2, dialyze_files/2, - halt_with_code/1]). - -%%---------------------------------------------------------------------------- - --ifdef(use_specs). - --spec(create_basic_plt/1 :: (file:filename()) -> 'ok'). --spec(add_to_plt/2 :: (file:filename(), string()) -> 'ok'). --spec(dialyze_files/2 :: (file:filename(), string()) -> 'ok'). --spec(halt_with_code/1 :: (atom()) -> no_return()). - --endif. - -%%---------------------------------------------------------------------------- - -create_basic_plt(BasicPltPath) -> - OptsRecord = dialyzer_options:build( - [{analysis_type, plt_build}, - {output_plt, BasicPltPath}, - {files_rec, otp_apps_dependencies_paths()}]), - dialyzer_cl:start(OptsRecord), - ok. - -add_to_plt(PltPath, FilesString) -> - Files = string:tokens(FilesString, " "), - DialyzerWarnings = dialyzer:run([{analysis_type, plt_add}, - {init_plt, PltPath}, - {output_plt, PltPath}, - {files, Files}]), - print_warnings(DialyzerWarnings, fun dialyzer:format_warning/1), - ok. - -dialyze_files(PltPath, ModifiedFiles) -> - Files = string:tokens(ModifiedFiles, " "), - DialyzerWarnings = dialyzer:run([{init_plt, PltPath}, - {files, Files}, - {warnings, [behaviours, - race_conditions]}]), - case DialyzerWarnings of - [] -> io:format("~nOk~n"); - _ -> io:format("~n~nFAILED with the following ~p warnings:~n~n", - [length(DialyzerWarnings)]), - print_warnings(DialyzerWarnings, fun dialyzer:format_warning/1) - end, - ok. - -print_warnings(Warnings, FormatFun) -> - [io:format("~s~n", [FormatFun(W)]) || W <- Warnings], - io:format("~n"). - -otp_apps_dependencies_paths() -> - [code:lib_dir(App, ebin) || - App <- [kernel, stdlib, sasl, mnesia, os_mon, ssl, eunit, tools]]. - -halt_with_code(ok) -> - halt(); -halt_with_code(fail) -> - halt(1). diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index 465642332c..61a24388f2 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -68,14 +68,14 @@ (name()) -> rabbit_types:exchange() | rabbit_types:channel_exit()). -spec(list/1 :: (rabbit_types:vhost()) -> [rabbit_types:exchange()]). --spec(info_keys/0 :: () -> [rabbit_types:info_key()]). --spec(info/1 :: (rabbit_types:exchange()) -> [rabbit_types:info()]). +-spec(info_keys/0 :: () -> rabbit_types:info_keys()). +-spec(info/1 :: (rabbit_types:exchange()) -> rabbit_types:infos()). -spec(info/2 :: - (rabbit_types:exchange(), [rabbit_types:info_key()]) - -> [rabbit_types:info()]). --spec(info_all/1 :: (rabbit_types:vhost()) -> [[rabbit_types:info()]]). --spec(info_all/2 ::(rabbit_types:vhost(), [rabbit_types:info_key()]) - -> [[rabbit_types:info()]]). + (rabbit_types:exchange(), rabbit_types:info_keys()) + -> rabbit_types:infos()). +-spec(info_all/1 :: (rabbit_types:vhost()) -> [rabbit_types:infos()]). +-spec(info_all/2 ::(rabbit_types:vhost(), rabbit_types:info_keys()) + -> [rabbit_types:infos()]). -spec(publish/2 :: (rabbit_types:exchange(), rabbit_types:delivery()) -> {rabbit_router:routing_result(), [pid()]}). -spec(delete/2 :: diff --git a/src/rabbit_framing.erl b/src/rabbit_framing.erl new file mode 100644 index 0000000000..a0c8f4d566 --- /dev/null +++ b/src/rabbit_framing.erl @@ -0,0 +1,64 @@ +%% The contents of this file are subject to the Mozilla Public License +%% Version 1.1 (the "License"); you may not use this file except in +%% compliance with the License. You may obtain a copy of the License at +%% http://www.mozilla.org/MPL/ +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +%% License for the specific language governing rights and limitations +%% under the License. +%% +%% The Original Code is RabbitMQ. +%% +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2010 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2010 Rabbit Technologies Ltd. +%% +%% All Rights Reserved. +%% +%% Contributor(s): ______________________________________. +%% + +%% TODO auto-generate + +-module(rabbit_framing). + +-ifdef(use_specs). + +-export_type([protocol/0, + amqp_field_type/0, amqp_property_type/0, + amqp_table/0, amqp_array/0, amqp_value/0, + amqp_method_name/0, amqp_method/0, amqp_method_record/0, + amqp_method_field_name/0, amqp_property_record/0, + amqp_exception/0, amqp_exception_code/0, amqp_class_id/0]). + +-type(protocol() :: 'rabbit_framing_amqp_0_8' | 'rabbit_framing_amqp_0_9_1'). + +-define(protocol_type(T), type(T :: rabbit_framing_amqp_0_8:T | + rabbit_framing_amqp_0_9_1:T)). + +-?protocol_type(amqp_field_type()). +-?protocol_type(amqp_property_type()). +-?protocol_type(amqp_table()). +-?protocol_type(amqp_array()). +-?protocol_type(amqp_value()). +-?protocol_type(amqp_method_name()). +-?protocol_type(amqp_method()). +-?protocol_type(amqp_method_record()). +-?protocol_type(amqp_method_field_name()). +-?protocol_type(amqp_property_record()). +-?protocol_type(amqp_exception()). +-?protocol_type(amqp_exception_code()). +-?protocol_type(amqp_class_id()). + +-endif. diff --git a/src/rabbit_invariable_queue.erl b/src/rabbit_invariable_queue.erl index 671634c464..5a0532eac1 100644 --- a/src/rabbit_invariable_queue.erl +++ b/src/rabbit_invariable_queue.erl @@ -52,7 +52,7 @@ -type(state() :: #iv_state { queue :: queue(), qname :: rabbit_amqqueue:name(), len :: non_neg_integer(), - pending_ack :: dict:dictionary() + pending_ack :: dict() }). -include("rabbit_backing_queue_spec.hrl"). diff --git a/src/rabbit_memory_monitor.erl b/src/rabbit_memory_monitor.erl index f87b62713a..bb4d77a4f7 100644 --- a/src/rabbit_memory_monitor.erl +++ b/src/rabbit_memory_monitor.erl @@ -63,8 +63,9 @@ %% have some space for when the queues don't quite respond as fast as %% we would like, or when there is buffering going on in other parts %% of the system. In short, we aim to stay some distance away from -%% when the memory alarms will go off, which cause channel.flow. -%% Note that all other Thresholds are relative to this scaling. +%% when the memory alarms will go off, which cause backpressure (of +%% some sort) on producers. Note that all other Thresholds are +%% relative to this scaling. -define(MEMORY_LIMIT_SCALING, 0.4). -define(LIMIT_THRESHOLD, 0.5). %% don't limit queues when mem use is < this diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index e5c30c0606..d5c8bd49cb 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -129,8 +129,8 @@ -spec(enable_cover/0 :: () -> ok_or_error()). -spec(start_cover/1 :: ([{string(), string()} | string()]) -> 'ok'). -spec(report_cover/0 :: () -> 'ok'). --spec(enable_cover/1 :: (file:filename()) -> ok_or_error()). --spec(report_cover/1 :: (file:filename()) -> 'ok'). +-spec(enable_cover/1 :: ([file:filename() | atom()]) -> ok_or_error()). +-spec(report_cover/1 :: ([file:filename() | atom()]) -> 'ok'). -spec(throw_on_error/2 :: (atom(), thunk(rabbit_types:error(any()) | {ok, A} | A)) -> A). -spec(with_exit_handler/2 :: (thunk(A), thunk(A)) -> A). @@ -178,10 +178,8 @@ -spec(recursive_delete/1 :: ([file:filename()]) -> rabbit_types:ok_or_error({file:filename(), any()})). --spec(dict_cons/3 :: (any(), any(), dict:dictionary()) -> - dict:dictionary()). --spec(orddict_cons/3 :: (any(), any(), orddict:dictionary()) -> - orddict:dictionary()). +-spec(dict_cons/3 :: (any(), any(), dict()) -> dict()). +-spec(orddict_cons/3 :: (any(), any(), orddict:orddict()) -> orddict:orddict()). -spec(unlink_and_capture_exit/1 :: (pid()) -> 'ok'). -spec(get_options/2 :: ([optdef()], [string()]) -> {[string()], [{string(), any()}]}). @@ -270,29 +268,30 @@ rs(#resource{virtual_host = VHostPath, kind = Kind, name = Name}) -> lists:flatten(io_lib:format("~s '~s' in vhost '~s'", [Kind, Name, VHostPath])). -enable_cover() -> - enable_cover("."). +enable_cover() -> enable_cover(["."]). -enable_cover([Root]) when is_atom(Root) -> - enable_cover(atom_to_list(Root)); -enable_cover(Root) -> - case cover:compile_beam_directory(filename:join(Root, "ebin")) of - {error,Reason} -> {error,Reason}; - _ -> ok - end. +enable_cover(Dirs) -> + lists:foldl(fun (Dir, ok) -> + case cover:compile_beam_directory( + filename:join(lists:concat([Dir]),"ebin")) of + {error, _} = Err -> Err; + _ -> ok + end; + (_Dir, Err) -> + Err + end, ok, Dirs). start_cover(NodesS) -> {ok, _} = cover:start([makenode(N) || N <- NodesS]), ok. -report_cover() -> - report_cover("."). +report_cover() -> report_cover(["."]). + +report_cover(Dirs) -> [report_cover1(lists:concat([Dir])) || Dir <- Dirs], ok. -report_cover([Root]) when is_atom(Root) -> - report_cover(atom_to_list(Root)); -report_cover(Root) -> +report_cover1(Root) -> Dir = filename:join(Root, "cover"), - ok = filelib:ensure_dir(filename:join(Dir,"junk")), + ok = filelib:ensure_dir(filename:join(Dir, "junk")), lists:foreach(fun (F) -> file:delete(F) end, filelib:wildcard(filename:join(Dir, "*.html"))), {ok, SummaryFile} = file:open(filename:join(Dir, "summary.txt"), [write]), diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl index 682a7faa62..fd84109bf9 100644 --- a/src/rabbit_msg_store.erl +++ b/src/rabbit_msg_store.erl @@ -130,7 +130,7 @@ -type(client_msstate() :: #client_msstate { server :: server(), client_ref :: client_ref(), - file_handle_cache :: dict:dictionary(), + file_handle_cache :: dict(), index_state :: any(), index_module :: atom(), dir :: file:filename(), @@ -164,8 +164,8 @@ -spec(set_maximum_since_use/2 :: (server(), non_neg_integer()) -> 'ok'). -spec(has_readers/2 :: (non_neg_integer(), gc_state()) -> boolean()). -spec(combine_files/3 :: (non_neg_integer(), non_neg_integer(), gc_state()) -> - non_neg_integer()). --spec(delete_file/2 :: (non_neg_integer(), gc_state()) -> non_neg_integer()). + 'ok'). +-spec(delete_file/2 :: (non_neg_integer(), gc_state()) -> 'ok'). -endif. diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl index 03a9b38679..1c542ffe7b 100644 --- a/src/rabbit_networking.erl +++ b/src/rabbit_networking.erl @@ -67,21 +67,21 @@ -spec(start/0 :: () -> 'ok'). -spec(start_tcp_listener/2 :: (hostname(), ip_port()) -> 'ok'). --spec(start_ssl_listener/3 :: (hostname(), ip_port(), [rabbit_types:info()]) +-spec(start_ssl_listener/3 :: (hostname(), ip_port(), rabbit_types:infos()) -> 'ok'). -spec(stop_tcp_listener/2 :: (hostname(), ip_port()) -> 'ok'). -spec(active_listeners/0 :: () -> [rabbit_types:listener()]). -spec(node_listeners/1 :: (node()) -> [rabbit_types:listener()]). -spec(connections/0 :: () -> [rabbit_types:connection()]). --spec(connection_info_keys/0 :: () -> [rabbit_types:info_key()]). +-spec(connection_info_keys/0 :: () -> rabbit_types:info_keys()). -spec(connection_info/1 :: - (rabbit_types:connection()) -> [rabbit_types:info()]). + (rabbit_types:connection()) -> rabbit_types:infos()). -spec(connection_info/2 :: - (rabbit_types:connection(), [rabbit_types:info_key()]) - -> [rabbit_types:info()]). --spec(connection_info_all/0 :: () -> [[rabbit_types:info()]]). + (rabbit_types:connection(), rabbit_types:info_keys()) + -> rabbit_types:infos()). +-spec(connection_info_all/0 :: () -> [rabbit_types:infos()]). -spec(connection_info_all/1 :: - ([rabbit_types:info_key()]) -> [[rabbit_types:info()]]). + (rabbit_types:info_keys()) -> [rabbit_types:infos()]). -spec(close_connection/2 :: (pid(), string()) -> 'ok'). -spec(on_node_down/1 :: (node()) -> 'ok'). -spec(check_tcp_listener_address/3 :: diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index 28d0b47dd6..bde9b3d3fe 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -190,7 +190,7 @@ unacked :: non_neg_integer() })). -type(seq_id() :: integer()). --type(seg_dict() :: {dict:dictionary(), [segment()]}). +-type(seg_dict() :: {dict(), [segment()]}). -type(qistate() :: #qistate { dir :: file:filename(), segments :: 'undefined' | seg_dict(), journal_handle :: hdl(), diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index 127467bb1f..7f7bd9d847 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -163,14 +163,14 @@ -ifdef(use_specs). -type(start_heartbeat_fun() :: - fun ((rabbit_networking:socket(), non_neg_integer()) -> + fun ((rabbit_net:socket(), non_neg_integer()) -> rabbit_heartbeat:heartbeaters())). -spec(start_link/3 :: (pid(), pid(), start_heartbeat_fun()) -> rabbit_types:ok(pid())). --spec(info_keys/0 :: () -> [rabbit_types:info_key()]). --spec(info/1 :: (pid()) -> [rabbit_types:info()]). --spec(info/2 :: (pid(), [rabbit_types:info_key()]) -> [rabbit_types:info()]). +-spec(info_keys/0 :: () -> rabbit_types:info_keys()). +-spec(info/1 :: (pid()) -> rabbit_types:infos()). +-spec(info/2 :: (pid(), rabbit_types:info_keys()) -> rabbit_types:infos()). -spec(emit_stats/1 :: (pid()) -> 'ok'). -spec(shutdown/2 :: (pid(), string()) -> 'ok'). -spec(conserve_memory/2 :: (pid(), boolean()) -> 'ok'). @@ -180,10 +180,10 @@ -spec(init/4 :: (pid(), pid(), pid(), start_heartbeat_fun()) -> no_return()). -spec(start_connection/7 :: (pid(), pid(), pid(), start_heartbeat_fun(), any(), - rabbit_networking:socket(), - fun ((rabbit_networking:socket()) -> + rabbit_net:socket(), + fun ((rabbit_net:socket()) -> rabbit_types:ok_or_error2( - rabbit_networking:socket(), any()))) -> no_return()). + rabbit_net:socket(), any()))) -> no_return()). -endif. diff --git a/src/rabbit_ssl.erl b/src/rabbit_ssl.erl index 4335dd2e40..5b9056826f 100644 --- a/src/rabbit_ssl.erl +++ b/src/rabbit_ssl.erl @@ -85,8 +85,8 @@ peer_cert_validity(Cert) -> cert_info(F, Cert) -> F(case public_key:pkix_decode_cert(Cert, otp) of - {ok, DecCert} -> DecCert; - DecCert -> DecCert + {ok, DecCert} -> DecCert; %%pre R14B + DecCert -> DecCert %%R14B onwards end). %%-------------------------------------------------------------------------- diff --git a/src/rabbit_types.erl b/src/rabbit_types.erl index edc73f7000..b9993823d1 100644 --- a/src/rabbit_types.erl +++ b/src/rabbit_types.erl @@ -35,7 +35,8 @@ -ifdef(use_specs). --export_type([txn/0, maybe/1, info/0, info_key/0, message/0, basic_message/0, +-export_type([txn/0, maybe/1, info/0, infos/0, info_key/0, info_keys/0, + message/0, basic_message/0, delivery/0, content/0, decoded_content/0, undecoded_content/0, unencoded_content/0, encoded_content/0, message_properties/0, vhost/0, ctag/0, amqp_error/0, r/1, r2/2, r3/3, listener/0, @@ -95,7 +96,10 @@ -type(txn() :: rabbit_guid:guid()). -type(info_key() :: atom()). +-type(info_keys() :: [info_key()]). + -type(info() :: {info_key(), any()}). +-type(infos() :: [info()]). -type(amqp_error() :: #amqp_error{name :: rabbit_framing:amqp_exception(), @@ -143,7 +147,7 @@ -type(connection() :: pid()). --type(protocol() :: 'rabbit_framing_amqp_0_8' | 'rabbit_framing_amqp_0_9_1'). +-type(protocol() :: rabbit_framing:protocol()). -type(user() :: #user{username :: rabbit_access_control:username(), diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl index f88e49c2f9..69d62fdeeb 100644 --- a/src/rabbit_variable_queue.erl +++ b/src/rabbit_variable_queue.erl @@ -305,7 +305,7 @@ q3 :: bpqueue:bpqueue(), q4 :: queue(), next_seq_id :: seq_id(), - pending_ack :: dict:dictionary(), + pending_ack :: dict(), index_state :: any(), msg_store_clients :: 'undefined' | {{any(), binary()}, {any(), binary()}}, diff --git a/src/rabbit_writer.erl b/src/rabbit_writer.erl index aa986e542b..50bca3909d 100644 --- a/src/rabbit_writer.erl +++ b/src/rabbit_writer.erl @@ -62,9 +62,10 @@ (pid(), rabbit_framing:amqp_method_record(), rabbit_types:content()) -> 'ok'). -spec(send_command_sync/2 :: - (pid(), rabbit_framing:amqp_method()) -> 'ok'). + (pid(), rabbit_framing:amqp_method_record()) -> 'ok'). -spec(send_command_sync/3 :: - (pid(), rabbit_framing:amqp_method(), rabbit_types:content()) -> 'ok'). + (pid(), rabbit_framing:amqp_method_record(), rabbit_types:content()) + -> 'ok'). -spec(send_command_and_notify/5 :: (pid(), pid(), pid(), rabbit_framing:amqp_method_record(), rabbit_types:content()) diff --git a/src/supervisor2.erl b/src/supervisor2.erl index 93adfcb1b5..46bab31ddc 100644 --- a/src/supervisor2.erl +++ b/src/supervisor2.erl @@ -357,8 +357,7 @@ handle_cast({delayed_restart, {RestartType, Reason, Child}}, State) when ?is_simple(State) -> {ok, NState} = do_restart(RestartType, Reason, Child, State), {noreply, NState}; -handle_cast({delayed_restart, {RestartType, Reason, Child}}, State) - when not (?is_simple(State)) -> +handle_cast({delayed_restart, {RestartType, Reason, Child}}, State) -> case get_child(Child#child.name, State) of {value, Child} -> {ok, NState} = do_restart(RestartType, Reason, Child, State), |
