diff options
| author | Matthias Radestock <matthias@lshift.net> | 2010-02-04 21:31:55 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2010-02-04 21:31:55 +0000 |
| commit | 21218f795e8416bbd9f0b3e091354b2e21367e37 (patch) | |
| tree | 9ac5f53793c053d6e4cdde13703fbc97527ff19a | |
| parent | f6c9404bc1977d7fbddde99d8f3916bcfb4bd1e8 (diff) | |
| parent | 75c480ff41d4568334a5bdc92c6aa6c8ee572516 (diff) | |
| download | rabbitmq-server-git-21218f795e8416bbd9f0b3e091354b2e21367e37.tar.gz | |
merge default into bug22309
| -rw-r--r-- | codegen.py | 7 | ||||
| -rw-r--r-- | src/rabbit_amqqueue.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 7 | ||||
| -rw-r--r-- | src/rabbit_binary_generator.erl | 17 | ||||
| -rw-r--r-- | src/rabbit_exchange.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_networking.erl | 12 | ||||
| -rw-r--r-- | src/rabbit_reader.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_tests.erl | 20 |
8 files changed, 46 insertions, 32 deletions
diff --git a/codegen.py b/codegen.py index 6f39574f26..648983f1f2 100644 --- a/codegen.py +++ b/codegen.py @@ -214,6 +214,8 @@ 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 @@ -246,7 +248,10 @@ def genErl(spec): elif type == 'table': 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 in ['shortstr', 'longstr']: + 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) + elif type == 'longstr': print " F%dLen = size(F%d)," % (f.index, f.index) else: pass diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 9e8e5d6cdb..db7461b09f 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -36,7 +36,7 @@ -export([pseudo_queue/2]). -export([lookup/1, with/2, with_or_die/2, stat/1, stat_all/0, deliver/2, redeliver/2, requeue/3, ack/4]). --export([list/1, info/1, info/2, info_all/1, info_all/2]). +-export([list/1, info_keys/0, info/1, info/2, info_all/1, info_all/2]). -export([claim_queue/2]). -export([basic_get/3, basic_consume/8, basic_cancel/4]). -export([notify_sent/2, unblock/2]). @@ -69,6 +69,7 @@ -spec(with/2 :: (queue_name(), qfun(A)) -> A | not_found()). -spec(with_or_die/2 :: (queue_name(), qfun(A)) -> A). -spec(list/1 :: (vhost()) -> [amqqueue()]). +-spec(info_keys/0 :: () -> [info_key()]). -spec(info/1 :: (amqqueue()) -> [info()]). -spec(info/2 :: (amqqueue(), [info_key()]) -> [info()]). -spec(info_all/1 :: (vhost()) -> [[info()]]). @@ -222,6 +223,8 @@ list(VHostPath) -> rabbit_queue, #amqqueue{name = rabbit_misc:r(VHostPath, queue), _ = '_'}). +info_keys() -> rabbit_amqqueue_process:info_keys(). + map(VHostPath, F) -> rabbit_misc:filter_exit_map(F, list(VHostPath)). info(#amqqueue{ pid = QPid }) -> diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index a3b0814cfa..06e68a1b16 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -39,7 +39,7 @@ -define(HIBERNATE_AFTER_MIN, 1000). -define(DESIRED_HIBERNATE, 10000). --export([start_link/1]). +-export([start_link/1, info_keys/0]). -export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2, handle_info/2]). @@ -88,9 +88,10 @@ %%---------------------------------------------------------------------------- -start_link(Q) -> - gen_server2:start_link(?MODULE, Q, []). +start_link(Q) -> gen_server2:start_link(?MODULE, Q, []). +info_keys() -> ?INFO_KEYS. + %%---------------------------------------------------------------------------- init(Q) -> diff --git a/src/rabbit_binary_generator.erl b/src/rabbit_binary_generator.erl index b8e161a6bd..b903a6eee7 100644 --- a/src/rabbit_binary_generator.erl +++ b/src/rabbit_binary_generator.erl @@ -196,12 +196,16 @@ generate_array(Array) when is_list(Array) -> fun ({Type, Value}) -> field_value_to_binary(Type, Value) end, Array)). -short_string_to_binary(String) when is_binary(String) and (size(String) < 256) -> - [<<(size(String)):8>>, String]; +short_string_to_binary(String) when is_binary(String) -> + Len = size(String), + if Len < 256 -> [<<(size(String)):8>>, String]; + true -> exit(content_properties_shortstr_overflow) + end; short_string_to_binary(String) -> StringLength = length(String), - true = (StringLength < 256), % assertion - [<<StringLength:8>>, String]. + if StringLength < 256 -> [<<StringLength:8>>, String]; + true -> exit(content_properties_shortstr_overflow) + end. long_string_to_binary(String) when is_binary(String) -> [<<(size(String)):32>>, String]; @@ -239,7 +243,10 @@ encode_properties(Bit, [T | TypeList], [Value | ValueList], FirstShortAcc, Flags end. encode_property(shortstr, String) -> - Len = size(String), <<Len:8/unsigned, String:Len/binary>>; + Len = size(String), + if Len < 256 -> <<Len:8/unsigned, String:Len/binary>>; + true -> exit(content_properties_shortstr_overflow) + end; encode_property(longstr, String) -> Len = size(String), <<Len:32/unsigned, String:Len/binary>>; encode_property(octet, Int) -> diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index c72ff7f9f7..33bfe89399 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -35,7 +35,7 @@ -include("rabbit_framing.hrl"). -export([recover/0, declare/5, lookup/1, lookup_or_die/1, - list/1, info/1, info/2, info_all/1, info_all/2, + list/1, info_keys/0, info/1, info/2, info_all/1, info_all/2, publish/2]). -export([add_binding/4, delete_binding/4, list_bindings/1]). -export([delete/2]). @@ -68,6 +68,7 @@ -spec(lookup/1 :: (exchange_name()) -> {'ok', exchange()} | not_found()). -spec(lookup_or_die/1 :: (exchange_name()) -> exchange()). -spec(list/1 :: (vhost()) -> [exchange()]). +-spec(info_keys/0 :: () -> [info_key()]). -spec(info/1 :: (exchange()) -> [info()]). -spec(info/2 :: (exchange(), [info_key()]) -> [info()]). -spec(info_all/1 :: (vhost()) -> [[info()]]). @@ -165,6 +166,8 @@ list(VHostPath) -> rabbit_exchange, #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}). +info_keys() -> ?INFO_KEYS. + map(VHostPath, F) -> %% TODO: there is scope for optimisation here, e.g. using a %% cursor, parallelising the function invocation diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl index 84be7918e9..06e2b40e47 100644 --- a/src/rabbit_networking.erl +++ b/src/rabbit_networking.erl @@ -32,10 +32,11 @@ -module(rabbit_networking). -export([boot/0, start/0, start_tcp_listener/2, start_ssl_listener/3, - stop_tcp_listener/2, on_node_down/1, active_listeners/0, - node_listeners/1, connections/0, connection_info/1, - connection_info/2, connection_info_all/0, - connection_info_all/1]). + stop_tcp_listener/2, on_node_down/1, active_listeners/0, + node_listeners/1, connections/0, connection_info_keys/0, + connection_info/1, connection_info/2, + connection_info_all/0, connection_info_all/1]). + %%used by TCP-based transports, e.g. STOMP adapter -export([check_tcp_listener_address/3]). @@ -70,6 +71,7 @@ -spec(active_listeners/0 :: () -> [listener()]). -spec(node_listeners/1 :: (erlang_node()) -> [listener()]). -spec(connections/0 :: () -> [connection()]). +-spec(connection_info_keys/0 :: () -> [info_key()]). -spec(connection_info/1 :: (connection()) -> [info()]). -spec(connection_info/2 :: (connection(), [info_key()]) -> [info()]). -spec(connection_info_all/0 :: () -> [[info()]]). @@ -214,6 +216,8 @@ connections() -> [Pid || {_, Pid, _, _} <- supervisor:which_children( rabbit_tcp_client_sup)]. +connection_info_keys() -> rabbit_reader:info_keys(). + connection_info(Pid) -> rabbit_reader:info(Pid). connection_info(Pid, Items) -> rabbit_reader:info(Pid, Items). diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index 90da2a7ee5..d0d8860fe2 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -33,7 +33,7 @@ -include("rabbit_framing.hrl"). -include("rabbit.hrl"). --export([start_link/0, info/1, info/2, shutdown/2]). +-export([start_link/0, info_keys/0, info/1, info/2, shutdown/2]). -export([system_continue/3, system_terminate/4, system_code_change/4]). @@ -129,6 +129,7 @@ -ifdef(use_specs). +-spec(info_keys/0 :: () -> [info_key()]). -spec(info/1 :: (pid()) -> [info()]). -spec(info/2 :: (pid(), [info_key()]) -> [info()]). -spec(shutdown/2 :: (pid(), string()) -> 'ok'). @@ -159,6 +160,8 @@ system_terminate(Reason, _Parent, _Deb, _State) -> system_code_change(Misc, _Module, _OldVsn, _Extra) -> {ok, Misc}. +info_keys() -> ?INFO_KEYS. + info(Pid) -> gen_server:call(Pid, info, infinity). diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 66bdd4cdc7..833ccc2638 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -695,18 +695,10 @@ test_server_status() -> false, false, []), %% list queues - ok = info_action( - list_queues, - [name, durable, auto_delete, arguments, pid, - messages_ready, messages_unacknowledged, messages_uncommitted, - messages, acks_uncommitted, consumers, transactions, memory], - true), + ok = info_action(list_queues, rabbit_amqqueue:info_keys(), true), %% list exchanges - ok = info_action( - list_exchanges, - [name, type, durable, auto_delete, arguments], - true), + ok = info_action(list_exchanges, rabbit_exchange:info_keys(), true), %% list bindings ok = control_action(list_bindings, []), @@ -721,12 +713,8 @@ test_server_status() -> {ok, C} = gen_tcp:connect(H, P, []), timer:sleep(100), - ok = info_action( - list_connections, - [pid, address, port, peer_address, peer_port, state, - channels, user, vhost, timeout, frame_max, - recv_oct, recv_cnt, send_oct, send_cnt, send_pend], - false), + ok = info_action(list_connections, + rabbit_networking:connection_info_keys(), false), ok = gen_tcp:close(C), passed. |
