summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Wragg <dpw@lshift.net>2009-08-07 13:08:20 +0100
committerDavid Wragg <dpw@lshift.net>2009-08-07 13:08:20 +0100
commit470d185f1ca1fd57ba3152f96fc42cab4e6b8127 (patch)
treea95475c6b836a90855342c187b4adb6701fb9a35
parente1aee692e99b1a14a4a1f5d94ea35847072aeee0 (diff)
parentcf63a15169420b5a1eb91414fb837e370157a857 (diff)
downloadrabbitmq-server-470d185f1ca1fd57ba3152f96fc42cab4e6b8127.tar.gz
Merged bug21202 into default
-rw-r--r--Makefile2
-rw-r--r--ebin/rabbit_app.in2
-rw-r--r--src/rabbit.erl17
-rw-r--r--src/rabbit_amqqueue.erl2
-rw-r--r--src/rabbit_basic.erl29
-rw-r--r--src/rabbit_channel.erl2
-rw-r--r--src/rabbit_misc.erl25
7 files changed, 60 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 9c372a28..5c7f6293 100644
--- a/Makefile
+++ b/Makefile
@@ -133,7 +133,7 @@ srcdist: distclean
cp README.in $(TARGET_SRC_DIR)/README
elinks -dump -no-references -no-numbering $(WEB_URL)build-server.html \
>> $(TARGET_SRC_DIR)/BUILD
- sed -i.save 's/%%VERSION%%/$(VERSION)/' $(TARGET_SRC_DIR)/ebin/rabbit_app.in && rm -f $(TARGET_SRC_DIR)/ebin/rabbit_app.in.save
+ sed -i.save 's/%%VSN%%/$(VERSION)/' $(TARGET_SRC_DIR)/ebin/rabbit_app.in && rm -f $(TARGET_SRC_DIR)/ebin/rabbit_app.in.save
cp -r $(AMQP_CODEGEN_DIR)/* $(TARGET_SRC_DIR)/codegen/
cp codegen.py Makefile generate_app $(TARGET_SRC_DIR)
diff --git a/ebin/rabbit_app.in b/ebin/rabbit_app.in
index 8e1c890e..0057ea04 100644
--- a/ebin/rabbit_app.in
+++ b/ebin/rabbit_app.in
@@ -1,7 +1,7 @@
{application, rabbit, %% -*- erlang -*-
[{description, "RabbitMQ"},
{id, "RabbitMQ"},
- {vsn, "%%VERSION%%"},
+ {vsn, "%%VSN%%"},
{modules, []},
{registered, [rabbit_amqqueue_sup,
rabbit_log,
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 196212ea..088fa436 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -207,8 +207,21 @@ log_location(Type) ->
print_banner() ->
{ok, Product} = application:get_key(id),
{ok, Version} = application:get_key(vsn),
- io:format("~s ~s (AMQP ~p-~p)~n~s~n~s~n~n",
- [Product, Version,
+ ProductLen = string:len(Product),
+ io:format("~n"
+ "+---+ +---+~n"
+ "| | | |~n"
+ "| | | |~n"
+ "| | | |~n"
+ "| +---+ +-------+~n"
+ "| |~n"
+ "| ~s +---+ |~n"
+ "| | | |~n"
+ "| ~s +---+ |~n"
+ "| |~n"
+ "+-------------------+~n"
+ "AMQP ~p-~p~n~s~n~s~n~n",
+ [Product, string:right([$v|Version], ProductLen),
?PROTOCOL_VERSION_MAJOR, ?PROTOCOL_VERSION_MINOR,
?COPYRIGHT_MESSAGE, ?INFORMATION_MESSAGE]),
Settings = [{"node", node()},
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index 198e2782..4903c2c5 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -51,8 +51,6 @@
-include("rabbit.hrl").
-include_lib("stdlib/include/qlc.hrl").
--define(CALL_TIMEOUT, 5000).
-
%%----------------------------------------------------------------------------
-ifdef(use_specs).
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl
index 2dc619c1..0f6aeb7a 100644
--- a/src/rabbit_basic.erl
+++ b/src/rabbit_basic.erl
@@ -35,6 +35,7 @@
-export([publish/1, message/4, properties/1, delivery/4]).
-export([publish/4, publish/7]).
+-export([build_content/2, from_content/1]).
%%----------------------------------------------------------------------------
@@ -53,6 +54,8 @@
-spec(publish/7 :: (exchange_name(), routing_key(), bool(), bool(),
maybe(txn()), properties_input(), binary()) ->
publish_result()).
+-spec(build_content/2 :: (amqp_properties(), binary()) -> content()).
+-spec(from_content/1 :: (content()) -> {amqp_properties(), binary()}).
-endif.
@@ -72,16 +75,30 @@ delivery(Mandatory, Immediate, Txn, Message) ->
#delivery{mandatory = Mandatory, immediate = Immediate, txn = Txn,
sender = self(), message = Message}.
+build_content(Properties, BodyBin) ->
+ {ClassId, _MethodId} = rabbit_framing:method_id('basic.publish'),
+ #content{class_id = ClassId,
+ properties = Properties,
+ properties_bin = none,
+ payload_fragments_rev = [BodyBin]}.
+
+from_content(#content{properties = Props,
+ properties_bin = none,
+ payload_fragments_rev = BodyList}) ->
+ {Props, list_to_binary(BodyList)};
+
+from_content(#content{properties = none,
+ properties_bin = PropsBin,
+ payload_fragments_rev = BodyList}) ->
+ {ClassId, _MethodId} = rabbit_framing:method_id('basic.publish'),
+ Props = rabbit_framing:decode_properties(ClassId, PropsBin),
+ {Props, list_to_binary(BodyList)}.
+
message(ExchangeName, RoutingKeyBin, RawProperties, BodyBin) ->
Properties = properties(RawProperties),
- {ClassId, _MethodId} = rabbit_framing:method_id('basic.publish'),
- Content = #content{class_id = ClassId,
- properties = Properties,
- properties_bin = none,
- payload_fragments_rev = [BodyBin]},
#basic_message{exchange_name = ExchangeName,
routing_key = RoutingKeyBin,
- content = Content,
+ content = build_content(Properties, BodyBin),
persistent_key = none}.
properties(P = #'P_basic'{}) ->
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 3089bb62..87664de3 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -89,7 +89,7 @@ deliver(Pid, ConsumerTag, AckRequired, Msg) ->
gen_server2:cast(Pid, {deliver, ConsumerTag, AckRequired, Msg}).
conserve_memory(Pid, Conserve) ->
- gen_server2:cast(Pid, {conserve_memory, Conserve}).
+ gen_server2:pcast(Pid, 9, {conserve_memory, Conserve}).
%%---------------------------------------------------------------------------
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 72e16f0f..abf4c7cc 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -41,6 +41,7 @@
-export([dirty_read/1]).
-export([r/3, r/2, r_arg/4, rs/1]).
-export([enable_cover/0, report_cover/0]).
+-export([enable_cover/1, report_cover/1]).
-export([throw_on_error/2, with_exit_handler/2, filter_exit_map/2]).
-export([with_user/2, with_vhost/2, with_user_and_vhost/3]).
-export([execute_mnesia_transaction/1]).
@@ -89,6 +90,8 @@
-spec(rs/1 :: (r(atom())) -> string()).
-spec(enable_cover/0 :: () -> 'ok' | {'error', any()}).
-spec(report_cover/0 :: () -> 'ok').
+-spec(enable_cover/1 :: (string()) -> 'ok' | {'error', any()}).
+-spec(report_cover/1 :: (string()) -> 'ok').
-spec(throw_on_error/2 ::
(atom(), thunk({error, any()} | {ok, A} | A)) -> A).
-spec(with_exit_handler/2 :: (thunk(A), thunk(A)) -> A).
@@ -188,17 +191,27 @@ rs(#resource{virtual_host = VHostPath, kind = Kind, name = Name}) ->
[Kind, Name, VHostPath])).
enable_cover() ->
- case cover:compile_beam_directory("ebin") of
+ 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.
report_cover() ->
- Dir = "cover/",
- ok = filelib:ensure_dir(Dir),
+ report_cover(".").
+
+report_cover([Root]) when is_atom(Root) ->
+ report_cover(atom_to_list(Root));
+report_cover(Root) ->
+ Dir = filename:join(Root, "cover"),
+ ok = filelib:ensure_dir(filename:join(Dir,"junk")),
lists:foreach(fun(F) -> file:delete(F) end,
- filelib:wildcard(Dir ++ "*.html")),
- {ok, SummaryFile} = file:open(Dir ++ "summary.txt", [write]),
+ filelib:wildcard(filename:join(Dir, "*.html"))),
+ {ok, SummaryFile} = file:open(filename:join(Dir, "summary.txt"), [write]),
{CT, NCT} =
lists:foldl(
fun(M,{CovTot, NotCovTot}) ->
@@ -207,7 +220,7 @@ report_cover() ->
Cov, NotCov, M),
{ok,_} = cover:analyze_to_file(
M,
- Dir ++ atom_to_list(M) ++ ".html",
+ filename:join(Dir, atom_to_list(M) ++ ".html"),
[html]),
{CovTot+Cov, NotCovTot+NotCov}
end,