summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2010-08-04 13:52:52 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2010-08-04 13:52:52 +0100
commite057aea4a27fbf180ee42ab54c7cee3c0b1eddf5 (patch)
treefccd2bcec312437cf0f6c69cbbf03db682f6d5b7
parent896ab1ca43156ca83f3a603cec273ef8d33630ea (diff)
parent0ec0c492b3e640426140a15be99c0adce99c133f (diff)
downloadrabbitmq-server-e057aea4a27fbf180ee42ab54c7cee3c0b1eddf5.tar.gz
merged default into bug22964
-rw-r--r--src/rabbit_access_control.erl8
-rw-r--r--src/rabbit_amqqueue.erl5
-rw-r--r--src/rabbit_basic.erl10
-rw-r--r--src/rabbit_exchange.erl38
-rw-r--r--src/rabbit_misc.erl15
-rw-r--r--src/rabbit_queue_collector.erl12
-rw-r--r--src/rabbit_reader.erl2
-rw-r--r--src/vm_memory_monitor.erl2
8 files changed, 41 insertions, 51 deletions
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl
index 61160edd..8a288e3d 100644
--- a/src/rabbit_access_control.erl
+++ b/src/rabbit_access_control.erl
@@ -56,7 +56,9 @@
-spec(check_login/2 ::
(binary(), binary()) -> rabbit_types:user() |
rabbit_types:channel_exit()).
--spec(user_pass_login/2 :: (username(), password()) -> rabbit_types:user()).
+-spec(user_pass_login/2 ::
+ (username(), password())
+ -> rabbit_types:user() | rabbit_types:channel_exit()).
-spec(check_vhost_access/2 ::
(rabbit_types:user(), rabbit_types:vhost())
-> 'ok' | rabbit_types:channel_exit()).
@@ -71,9 +73,9 @@
(username()) -> rabbit_types:ok(rabbit_types:user())
| rabbit_types:error('not_found')).
-spec(add_vhost/1 ::
- (rabbit_types:vhost()) -> 'ok' | rabbit_types:connection_exit()).
+ (rabbit_types:vhost()) -> 'ok').
-spec(delete_vhost/1 ::
- (rabbit_types:vhost()) -> 'ok' | rabbit_types:connection_exit()).
+ (rabbit_types:vhost()) -> 'ok').
-spec(list_vhosts/0 :: () -> [rabbit_types:vhost()]).
-spec(set_permissions/5 ::(username(), rabbit_types:vhost(), regexp(),
regexp(), regexp()) -> 'ok').
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index f9f8e2ec..d4226331 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -150,8 +150,7 @@
-spec(flush_all/2 :: ([pid()], pid()) -> 'ok').
-spec(internal_declare/2 ::
(rabbit_types:amqqueue(), boolean())
- -> rabbit_types:amqqueue() | 'not_found' |
- rabbit_types:connection_exit()).
+ -> rabbit_types:amqqueue() | 'not_found').
-spec(internal_delete/1 ::
(name()) -> rabbit_types:ok_or_error('not_found') |
rabbit_types:connection_exit()).
@@ -161,7 +160,7 @@
-spec(set_ram_duration_target/2 :: (pid(), number() | 'infinity') -> 'ok').
-spec(set_maximum_since_use/2 :: (pid(), non_neg_integer()) -> 'ok').
-spec(maybe_expire/1 :: (pid()) -> 'ok').
--spec(on_node_down/1 :: (node()) -> 'ok' | rabbit_types:connection_exit()).
+-spec(on_node_down/1 :: (node()) -> 'ok').
-spec(pseudo_queue/2 :: (binary(), pid()) -> rabbit_types:amqqueue()).
-endif.
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl
index b536fa79..c1445a0c 100644
--- a/src/rabbit_basic.erl
+++ b/src/rabbit_basic.erl
@@ -49,12 +49,10 @@
| rabbit_types:error('not_found'))).
-spec(publish/1 ::
- (rabbit_types:delivery()) -> publish_result() |
- rabbit_types:connection_exit()).
+ (rabbit_types:delivery()) -> publish_result()).
-spec(delivery/4 ::
(boolean(), boolean(), rabbit_types:maybe(rabbit_types:txn()),
- rabbit_types:message())
- -> rabbit_types:delivery()).
+ rabbit_types:message()) -> rabbit_types:delivery()).
-spec(message/4 ::
(rabbit_exchange:name(), rabbit_router:routing_key(),
properties_input(), binary())
@@ -64,12 +62,12 @@
-spec(publish/4 ::
(rabbit_exchange:name(), rabbit_router:routing_key(),
properties_input(), binary())
- -> publish_result() | rabbit_types:connection_exit()).
+ -> publish_result()).
-spec(publish/7 ::
(rabbit_exchange:name(), rabbit_router:routing_key(),
boolean(), boolean(), rabbit_types:maybe(rabbit_types:txn()),
properties_input(), binary())
- -> publish_result() | rabbit_types:connection_exit()).
+ -> publish_result()).
-spec(build_content/2 ::
(rabbit_framing:amqp_property_record(), binary())
-> rabbit_types:content()).
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl
index 75154388..af4eb1bd 100644
--- a/src/rabbit_exchange.erl
+++ b/src/rabbit_exchange.erl
@@ -67,10 +67,10 @@
fun((rabbit_types:exchange(), queue()) ->
rabbit_types:ok_or_error(rabbit_types:amqp_error()))).
--spec(recover/0 :: () -> 'ok' | rabbit_types:connection_exit()).
+-spec(recover/0 :: () -> 'ok').
-spec(declare/5 ::
(name(), type(), boolean(), boolean(), rabbit_framing:amqp_table())
- -> rabbit_types:exchange() | rabbit_types:connection_exit()).
+ -> rabbit_types:exchange()).
-spec(check_type/1 ::
(binary()) -> atom() | rabbit_types:connection_exit()).
-spec(assert_equivalence/5 ::
@@ -96,32 +96,26 @@
-spec(info_all/2 ::(rabbit_types:vhost(), [rabbit_types:info_key()])
-> [[rabbit_types:info()]]).
-spec(publish/2 :: (rabbit_types:exchange(), rabbit_types:delivery())
- -> {rabbit_router:routing_result(), [pid()]} |
- rabbit_types:connection_exit()).
+ -> {rabbit_router:routing_result(), [pid()]}).
-spec(add_binding/5 ::
(name(), rabbit_amqqueue:name(), rabbit_router:routing_key(),
- rabbit_framing:amqp_table(), inner_fun())
- -> bind_res() | rabbit_types:connection_exit()).
+ rabbit_framing:amqp_table(), inner_fun()) -> bind_res()).
-spec(delete_binding/5 ::
(name(), rabbit_amqqueue:name(), rabbit_router:routing_key(),
rabbit_framing:amqp_table(), inner_fun())
- -> bind_res() | rabbit_types:error('binding_not_found') |
- rabbit_types:connection_exit()).
+ -> bind_res() | rabbit_types:error('binding_not_found')).
-spec(list_bindings/1 ::
(rabbit_types:vhost())
-> [{name(), rabbit_amqqueue:name(), rabbit_router:routing_key(),
rabbit_framing:amqp_table()}]).
-spec(delete_queue_bindings/1 ::
- (rabbit_amqqueue:name())
- -> fun (() -> none()) | rabbit_types:connection_exit()).
+ (rabbit_amqqueue:name()) -> fun (() -> any())).
-spec(delete_transient_queue_bindings/1 ::
- (rabbit_amqqueue:name())
- -> fun (() -> none()) | rabbit_types:connection_exit()).
+ (rabbit_amqqueue:name()) -> fun (() -> any())).
-spec(delete/2 ::
(name(), boolean())-> 'ok' |
rabbit_types:error('not_found') |
- rabbit_types:error('in_use') |
- rabbit_types:connection_exit()).
+ rabbit_types:error('in_use')).
-spec(list_queue_bindings/1 ::
(rabbit_amqqueue:name())
-> [{name(), rabbit_router:routing_key(),
@@ -208,12 +202,8 @@ declare(ExchangeName, Type, Durable, AutoDelete, Args) ->
%% Used with atoms from records; e.g., the type is expected to exist.
type_to_module(T) ->
- case rabbit_exchange_type_registry:lookup_module(T) of
- {ok, Module} -> Module;
- {error, not_found} -> rabbit_misc:protocol_error(
- command_invalid,
- "invalid exchange type '~s'", [T])
- end.
+ {ok, Module} = rabbit_exchange_type_registry:lookup_module(T),
+ Module.
%% Used with binaries sent over the wire; the type may not exist.
check_type(TypeBin) ->
@@ -222,8 +212,12 @@ check_type(TypeBin) ->
rabbit_misc:protocol_error(
command_invalid, "unknown exchange type '~s'", [TypeBin]);
T ->
- _Module = type_to_module(T),
- T
+ case rabbit_exchange_type_registry:lookup_module(T) of
+ {error, not_found} -> rabbit_misc:protocol_error(
+ command_invalid,
+ "invalid exchange type '~s'", [T]);
+ {ok, _Module} -> T
+ end
end.
assert_equivalence(X = #exchange{ durable = Durable,
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 4827506b..638596b7 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -81,14 +81,15 @@
-type(thunk(T) :: fun(() -> T)).
-type(resource_name() :: binary()).
-type(optdef() :: {flag, string()} | {option, string(), any()}).
+-type(channel_or_connection_exit()
+ :: rabbit_types:channel_exit() | rabbit_types:connection_exit()).
-spec(method_record_type/1 :: (rabbit_framing:amqp_method_record())
-> rabbit_framing:amqp_method_name()).
-spec(polite_pause/0 :: () -> 'done').
-spec(polite_pause/1 :: (non_neg_integer()) -> 'done').
-spec(die/1 ::
- (rabbit_framing:amqp_exception())
- -> rabbit_types:channel_exit() | rabbit_types:connection_exit()).
+ (rabbit_framing:amqp_exception()) -> channel_or_connection_exit()).
-spec(frame_error/2 :: (rabbit_framing:amqp_method_name(), binary())
-> rabbit_types:connection_exit()).
-spec(amqp_error/4 ::
@@ -96,14 +97,12 @@
rabbit_framing:amqp_method_name())
-> rabbit_types:amqp_error()).
-spec(protocol_error/3 :: (rabbit_framing:amqp_exception(), string(), [any()])
- -> rabbit_types:channel_exit() |
- rabbit_types:connection_exit()).
+ -> channel_or_connection_exit()).
-spec(protocol_error/4 ::
(rabbit_framing:amqp_exception(), string(), [any()],
- rabbit_framing:amqp_method_name())
- -> rabbit_types:channel_exit() |
- rabbit_types:connection_exit()).
--spec(protocol_error/1 :: (rabbit_types:amqp_error()) -> no_return()).
+ rabbit_framing:amqp_method_name()) -> channel_or_connection_exit()).
+-spec(protocol_error/1 ::
+ (rabbit_types:amqp_error()) -> channel_or_connection_exit()).
-spec(not_found/1 :: (rabbit_types:r(atom())) -> rabbit_types:channel_exit()).
-spec(assert_args_equivalence/4 :: (rabbit_framing:amqp_table(),
rabbit_framing:amqp_table(),
diff --git a/src/rabbit_queue_collector.erl b/src/rabbit_queue_collector.erl
index ea3768d4..9257ec82 100644
--- a/src/rabbit_queue_collector.erl
+++ b/src/rabbit_queue_collector.erl
@@ -49,6 +49,7 @@
-spec(start_link/0 :: () -> rabbit_types:ok(pid())).
-spec(register/2 :: (pid(), rabbit_types:amqqueue()) -> 'ok').
-spec(delete_all/1 :: (pid()) -> 'ok').
+-spec(shutdown/1 :: (pid()) -> 'ok').
-endif.
@@ -64,7 +65,7 @@ delete_all(CollectorPid) ->
gen_server:call(CollectorPid, delete_all, infinity).
shutdown(CollectorPid) ->
- gen_server:call(CollectorPid, shutdown, infinity).
+ gen_server:cast(CollectorPid, shutdown).
%%----------------------------------------------------------------------------
@@ -87,13 +88,10 @@ handle_call(delete_all, _From, State = #state{queues = Queues}) ->
rabbit_amqqueue:delete(Q, false, false)
end)
|| {MonitorRef, Q} <- dict:to_list(Queues)],
- {reply, ok, State};
+ {reply, ok, State}.
-handle_call(shutdown, _From, State) ->
- {stop, normal, ok, State}.
-
-handle_cast(_Msg, State) ->
- {noreply, State}.
+handle_cast(shutdown, State) ->
+ {stop, normal, State}.
handle_info({'DOWN', MonitorRef, process, _DownPid, _Reason},
State = #state{queues = Queues}) ->
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 17443926..532572fd 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -285,8 +285,8 @@ start_connection(Parent, Deb, Sock, SockTransform) ->
%%
%% gen_tcp:close(ClientSock),
teardown_profiling(ProfilingValue),
- rabbit_queue_collector:shutdown(Collector),
rabbit_misc:unlink_and_capture_exit(Collector),
+ rabbit_queue_collector:shutdown(Collector),
rabbit_event:notify(connection_closed, [{pid, self()}])
end,
done.
diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl
index bbc3a8c0..3cbc80f8 100644
--- a/src/vm_memory_monitor.erl
+++ b/src/vm_memory_monitor.erl
@@ -78,7 +78,7 @@
rabbit_types:ok(pid())).
-spec(update/0 :: () -> 'ok').
-spec(get_total_memory/0 :: () -> (non_neg_integer() | 'unknown')).
--spec(get_vm_limit/0 :: () -> (non_neg_integer() | 'unknown')).
+-spec(get_vm_limit/0 :: () -> non_neg_integer()).
-spec(get_memory_limit/0 :: () -> (non_neg_integer() | 'undefined')).
-spec(get_check_interval/0 :: () -> non_neg_integer()).
-spec(set_check_interval/1 :: (non_neg_integer()) -> 'ok').