diff --git a/.gitignore b/.gitignore index 3c2a2f1..6ae79ad 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /basho-riak_core-1.3.0-0-gc08df0d.tar.gz /basho-riak_core-1.3.1-0-g96d5dc3.tar.gz /basho-riak_core-1.3.2-0-g5f683f5.tar.gz +/riak_core-2.1.5.tar.gz diff --git a/erlang-riak_core-0001-Fix-rebar-deps.patch b/erlang-riak_core-0001-Fix-rebar-deps.patch deleted file mode 100644 index 102ef76..0000000 --- a/erlang-riak_core-0001-Fix-rebar-deps.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 5865dfb100aac2542819d574757574c39735c64b Mon Sep 17 00:00:00 2001 -From: Peter Lemenkov -Date: Sun, 24 Mar 2013 10:46:32 +0400 -Subject: [PATCH 1/2] Fix rebar deps - -Signed-off-by: Peter Lemenkov ---- - rebar.config | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/rebar.config b/rebar.config -index d32b147..d09d67f 100644 ---- a/rebar.config -+++ b/rebar.config -@@ -11,7 +11,7 @@ - {tag, "0.8.0"}}}, - {basho_stats, "1.0.3", {git, "git://github.com/basho/basho_stats", {tag, "1.0.3"}}}, - {riak_sysmon, "1.1.3", {git, "git://github.com/basho/riak_sysmon", {tag, "1.1.3"}}}, -- {webmachine, "1.9.3", {git, "git://github.com/basho/webmachine", -+ {webmachine, "1.*", {git, "git://github.com/basho/webmachine", - {tag, "1.9.3"}}}, - {folsom, ".*", {git, "git://github.com/basho/folsom.git", {tag, "0.7.3p1"}}} - ]}. --- -1.8.3.1 - diff --git a/erlang-riak_core-0001-Use-a-new-riak_core_util-unique_seed-0-function.patch b/erlang-riak_core-0001-Use-a-new-riak_core_util-unique_seed-0-function.patch new file mode 100644 index 0000000..2407a6b --- /dev/null +++ b/erlang-riak_core-0001-Use-a-new-riak_core_util-unique_seed-0-function.patch @@ -0,0 +1,181 @@ +From: matehat +Date: Wed, 23 Dec 2015 11:03:09 -0500 +Subject: [PATCH] Use a new riak_core_util:unique_seed/0 function + +replacing erlang:now/0 + +diff --git a/src/hashtree.erl b/src/hashtree.erl +index dc72cac..25600b6 100644 +--- a/src/hashtree.erl ++++ b/src/hashtree.erl +@@ -645,7 +645,7 @@ new_segment_store(Opts, State) -> + DataDir = case proplists:get_value(segment_path, Opts) of + undefined -> + Root = "/tmp/anti/level", +- <> = md5(term_to_binary({erlang:now(), make_ref()})), ++ <> = md5(term_to_binary({erlang:unique_integer(), make_ref()})), + filename:join(Root, integer_to_list(P)); + SegmentPath -> + SegmentPath +@@ -662,7 +662,7 @@ new_segment_store(Opts, State) -> + %% flushed to disk at once when under a heavy uniform load. + WriteBufferMin = proplists:get_value(write_buffer_size_min, Config, DefaultWriteBufferMin), + WriteBufferMax = proplists:get_value(write_buffer_size_max, Config, DefaultWriteBufferMax), +- {Offset, _} = random:uniform_s(1 + WriteBufferMax - WriteBufferMin, now()), ++ {Offset, _} = random:uniform_s(1 + WriteBufferMax - WriteBufferMin, riak_core_util:unique_seed()), + WriteBufferSize = WriteBufferMin + Offset, + Config2 = orddict:store(write_buffer_size, WriteBufferSize, Config), + Config3 = orddict:erase(write_buffer_size_min, Config2), +diff --git a/src/hashtree_tree.erl b/src/hashtree_tree.erl +index 2036404..2bdba54 100644 +--- a/src/hashtree_tree.erl ++++ b/src/hashtree_tree.erl +@@ -565,7 +565,7 @@ data_root(Opts) -> + case proplists:get_value(data_dir, Opts) of + undefined -> + Base = "/tmp/hashtree_tree", +- <> = riak_core_util:md5(term_to_binary(erlang:now())), ++ <> = riak_core_util:md5(term_to_binary(erlang:unique_integer())), + filename:join(Base, riak_core_util:integer_to_list(P, 16)); + Root -> Root + end. +diff --git a/src/riak_core_claimant.erl b/src/riak_core_claimant.erl +index ca09457..923af0e 100644 +--- a/src/riak_core_claimant.erl ++++ b/src/riak_core_claimant.erl +@@ -223,7 +223,7 @@ bucket_type_iterator() -> + %%%=================================================================== + + reassign_indices(CState) -> +- reassign_indices(CState, [], erlang:now(), fun no_log/2). ++ reassign_indices(CState, [], riak_core_util:unique_seed(), fun no_log/2). + + %%%=================================================================== + %%% Internal API helpers +@@ -250,7 +250,7 @@ maybe_filter_inactive_type(true, Default, Props) -> + + init([]) -> + schedule_tick(), +- {ok, #state{changes=[], seed=erlang:now()}}. ++ {ok, #state{changes=[], seed=riak_core_util:unique_seed()}}. + + handle_call(clear, _From, State) -> + State2 = clear_staged(State), +@@ -388,7 +388,7 @@ commit_staged(State) -> + {ok, _} -> + State2 = State#state{next_ring=undefined, + changes=[], +- seed=erlang:now()}, ++ seed=riak_core_util:unique_seed()}, + {ok, State2}; + not_changed -> + {error, State}; +@@ -438,7 +438,7 @@ maybe_commit_staged(Ring, NextRing, #state{next_ring=PlannedRing}) -> + %% call {@link clear/0}. + clear_staged(State) -> + remove_joining_nodes(), +- State#state{changes=[], seed=erlang:now()}. ++ State#state{changes=[], seed=riak_core_util:unique_seed()}. + + %% @private + remove_joining_nodes() -> +@@ -662,7 +662,7 @@ maybe_force_ring_update(Ring) -> + end. + + do_maybe_force_ring_update(Ring) -> +- case compute_next_ring([], erlang:now(), Ring) of ++ case compute_next_ring([], riak_core_util:unique_seed(), Ring) of + {ok, NextRing} -> + case same_plan(Ring, NextRing) of + false -> +@@ -1109,7 +1109,7 @@ internal_ring_changed(Node, CState) -> + %% Set cluster name if it is undefined + case {IsClaimant, riak_core_ring:cluster_name(CState5)} of + {true, undefined} -> +- ClusterName = {Node, erlang:now()}, ++ ClusterName = {Node, riak_core_util:unique_seed()}, + {_,_} = riak_core_util:rpc_every_member(riak_core_ring_manager, + set_cluster_name, + [ClusterName], +@@ -1143,7 +1143,7 @@ do_claimant_quiet(Node, CState, Replacing, Seed) -> + do_claimant(Node, CState, Replacing, Seed, fun no_log/2). + + do_claimant(Node, CState, Log) -> +- do_claimant(Node, CState, [], erlang:now(), Log). ++ do_claimant(Node, CState, [], riak_core_util:unique_seed(), Log). + + do_claimant(Node, CState, Replacing, Seed, Log) -> + AreJoining = are_joining_nodes(CState), +diff --git a/src/riak_core_gossip.erl b/src/riak_core_gossip.erl +index d709a50..cfb8169 100644 +--- a/src/riak_core_gossip.erl ++++ b/src/riak_core_gossip.erl +@@ -397,7 +397,7 @@ log_node_removed(Node, Old) -> + lager:info("'~s' removed from cluster (previously: '~s')~n", [Node, Old]). + + remove_from_cluster(Ring, ExitingNode) -> +- remove_from_cluster(Ring, ExitingNode, erlang:now()). ++ remove_from_cluster(Ring, ExitingNode, riak_core_util:unique_seed()). + + remove_from_cluster(Ring, ExitingNode, Seed) -> + % Get a list of indices owned by the ExitingNode... +diff --git a/src/riak_core_ring.erl b/src/riak_core_ring.erl +index a20e2c2..930b26f 100644 +--- a/src/riak_core_ring.erl ++++ b/src/riak_core_ring.erl +@@ -357,7 +357,7 @@ fresh(RingSize, NodeName) -> + VClock=vclock:increment(NodeName, vclock:fresh()), + GossipVsn = riak_core_gossip:gossip_version(), + ?CHSTATE{nodename=NodeName, +- clustername={NodeName, erlang:now()}, ++ clustername={NodeName, riak_core_util:unique_seed()}, + members=[{NodeName, {valid, VClock, [{gossip_vsn, GossipVsn}]}}], + chring=chash:fresh(RingSize, NodeName), + next=[], +diff --git a/src/riak_core_ring_manager.erl b/src/riak_core_ring_manager.erl +index 2900727..896c4f6 100644 +--- a/src/riak_core_ring_manager.erl ++++ b/src/riak_core_ring_manager.erl +@@ -222,7 +222,7 @@ force_update() -> + ring_trans( + fun(Ring, _) -> + NewRing = riak_core_ring:update_member_meta(node(), Ring, node(), +- unused, now()), ++ unused, riak_core_util:unique_seed()), + {new_ring, NewRing} + end, []), + ok. +diff --git a/src/riak_core_util.erl b/src/riak_core_util.erl +index d1b50bf..7089088 100644 +--- a/src/riak_core_util.erl ++++ b/src/riak_core_util.erl +@@ -67,7 +67,8 @@ + make_fold_req/4, + make_newest_fold_req/1, + proxy_spawn/1, +- proxy/2 ++ proxy/2, ++ unique_seed/0 + ]). + + -include("riak_core_vnode.hrl"). +@@ -942,3 +943,6 @@ proxy_spawn_test() -> + + -endif. + ++unique_seed() -> ++ {erlang:unique_integer([positive]), erlang:unique_integer([positive]), ++ erlang:unique_integer([positive])}. +diff --git a/src/supervisor_pre_r14b04.erl b/src/supervisor_pre_r14b04.erl +index d007c92..7b652f4 100644 +--- a/src/supervisor_pre_r14b04.erl ++++ b/src/supervisor_pre_r14b04.erl +@@ -1188,7 +1188,7 @@ add_restart(State) -> + I = State#state.intensity, + P = State#state.period, + R = State#state.restarts, +- Now = erlang:now(), ++ Now = erlang:timestamp(), + R1 = add_restart([Now|R], Now, P), + State1 = State#state{restarts = R1}, + case length(R1) of diff --git a/erlang-riak_core-0002-Fix-chashbin-record-typespec-warning.patch b/erlang-riak_core-0002-Fix-chashbin-record-typespec-warning.patch new file mode 100644 index 0000000..01a0a48 --- /dev/null +++ b/erlang-riak_core-0002-Fix-chashbin-record-typespec-warning.patch @@ -0,0 +1,18 @@ +From: matehat +Date: Wed, 23 Dec 2015 11:03:28 -0500 +Subject: [PATCH] Fix chashbin record typespec warning + + +diff --git a/src/chashbin.erl b/src/chashbin.erl +index 54a971b..e0114c5 100644 +--- a/src/chashbin.erl ++++ b/src/chashbin.erl +@@ -37,7 +37,7 @@ + + -record(chashbin, {size :: pos_integer(), + owners :: owners_bin(), +- nodes :: tuple(node())}). ++ nodes :: {node()}}). + + -type chashbin() :: #chashbin{}. + diff --git a/erlang-riak_core-0002-Fix-overload-test-time-outs.patch b/erlang-riak_core-0002-Fix-overload-test-time-outs.patch deleted file mode 100644 index 6847fd9..0000000 --- a/erlang-riak_core-0002-Fix-overload-test-time-outs.patch +++ /dev/null @@ -1,80 +0,0 @@ -From a757c328f443bffd9e25590ebab3e1a723965175 Mon Sep 17 00:00:00 2001 -From: "Engel A. Sanchez" -Date: Tue, 28 May 2013 10:25:41 -0400 -Subject: [PATCH 2/2] Fix overload test time outs - -Testing slow vnodes tends to time out, so upping the eunit timeout -values. -The gen:call was timing out with its 5 second default instead of obeying -the eunit test timeout, so it was changed to infinity. ---- - src/riak_core_vnode_proxy.erl | 16 ++++++++-------- - 1 file changed, 8 insertions(+), 8 deletions(-) - -diff --git a/src/riak_core_vnode_proxy.erl b/src/riak_core_vnode_proxy.erl -index 3091149..1948345 100644 ---- a/src/riak_core_vnode_proxy.erl -+++ b/src/riak_core_vnode_proxy.erl -@@ -336,7 +336,7 @@ fake_loop_block() -> - end. - - overload_test_() -> -- {foreach, -+ {timeout, 900, {foreach, - fun() -> - VnodePid = spawn(fun fake_loop/0), - meck:new(riak_core_vnode_manager, [passthrough]), -@@ -355,11 +355,11 @@ overload_test_() -> - end, - [ - fun({VnodePid, ProxyPid}) -> -- {"should not discard in normal operation", -+ {"should not discard in normal operation", timeout, 60, - fun() -> - [ProxyPid ! hello || _ <- lists:seq(1, 50000)], - %% synchronize on the mailbox -- Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync), -+ Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync, infinity), - ?assertEqual({ok, ok}, Reply), - VnodePid ! {get_count, self()}, - receive -@@ -371,12 +371,12 @@ overload_test_() -> - } - end, - fun({VnodePid, ProxyPid}) -> -- {"should discard during overflow", -+ {"should discard during overflow", timeout, 60, - fun() -> - VnodePid ! block, - [ProxyPid ! hello || _ <- lists:seq(1, 50000)], - %% synchronize on the mailbox -- Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync), -+ Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync, infinity), - ?assertEqual({ok, ok}, Reply), - VnodePid ! unblock, - VnodePid ! {get_count, self()}, -@@ -389,12 +389,12 @@ overload_test_() -> - } - end, - fun({VnodePid, ProxyPid}) -> -- {"should tolerate slow vnodes", -+ {"should tolerate slow vnodes", timeout, 60, - fun() -> - VnodePid ! slow, - [ProxyPid ! hello || _ <- lists:seq(1, 50000)], - %% synchronize on the mailbox -- Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync), -+ Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync, infinity), - ?assertEqual({ok, ok}, Reply), - %% check that the outstanding message count is - %% reasonable -@@ -405,5 +405,5 @@ overload_test_() -> - end - } - end -- ]}. -+ ]}}. - -endif. --- -1.8.3.1 - diff --git a/erlang-riak_core-0003-Don-t-use-pbkdf2-as-application.patch b/erlang-riak_core-0003-Don-t-use-pbkdf2-as-application.patch new file mode 100644 index 0000000..193065e --- /dev/null +++ b/erlang-riak_core-0003-Don-t-use-pbkdf2-as-application.patch @@ -0,0 +1,236 @@ +From: Peter Lemenkov +Date: Fri, 22 Apr 2016 16:45:41 +0300 +Subject: [PATCH] Don't use pbkdf2 as application + +Use pbkdf2 from basho/erlang-pbkdf2@0cabf7cc8c18e820d9149d08cb64ed6cc5aae3b4. + +Signed-off-by: Peter Lemenkov + +diff --git a/rebar.config b/rebar.config +index c4be06f..36583b9 100644 +--- a/rebar.config ++++ b/rebar.config +@@ -15,7 +15,6 @@ + {basho_stats, ".*", {git, "git://github.com/basho/basho_stats.git", {tag, "1.0.3"}}}, + {riak_sysmon, ".*", {git, "git://github.com/basho/riak_sysmon.git", {branch, "2.1"}}}, + {riak_ensemble, ".*", {git, "git://github.com/basho/riak_ensemble", {branch, "2.1"}}}, +- {pbkdf2, ".*", {git, "git://github.com/basho/erlang-pbkdf2.git", {tag, "2.0.0"}}}, + {eleveldb, ".*", {git, "git://github.com/basho/eleveldb.git", {tag, "2.1.10"}}}, + {exometer_core, ".*", {git, "git://github.com/basho/exometer_core.git", {tag, "1.0.0-basho2"}}}, + {clique, "0.3.2", {git, "git://github.com/basho/clique.git", {tag, "0.3.2"}}} +diff --git a/src/pbkdf2.erl b/src/pbkdf2.erl +new file mode 100644 +index 0000000..dcc6606 +--- /dev/null ++++ b/src/pbkdf2.erl +@@ -0,0 +1,198 @@ ++% Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 ++% ++% Unless required by applicable law or agreed to in writing, software ++% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT ++% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the ++% License for the specific language governing permissions and limitations under ++% the License. ++ ++-module(pbkdf2). ++ ++-export([pbkdf2/4, pbkdf2/5, compare_secure/2, to_hex/1]). ++ ++ ++%-type(hex_char() :: $0 .. $9 | $a .. $f). ++-type(hex_char() :: 48 .. 57 | 97 .. 102). ++-type(hex_list() :: [hex_char()]). ++ ++ ++-type digest_func_info() :: md4 | md5 | ripemd160 | sha | sha224 | sha256 | sha384 | sha512. ++ ++-type mac_func_info() :: {hmac, digest_func_info()} | digest_func_info(). ++ ++ ++-define(MAX_DERIVED_KEY_LENGTH, (1 bsl 32 - 1)). ++ ++%====================================================================================================================== ++% Public API ++ ++-spec pbkdf2(MacFunc, Password, Salt, Iterations) -> {ok, Key} | {error, derived_key_too_long} when ++ MacFunc :: mac_func_info(), ++ Password :: binary(), ++ Salt :: binary(), ++ Iterations :: integer(), ++ Key :: binary(). ++ ++pbkdf2(MacFunc, Password, Salt, Iterations) -> ++ MacFunc1 = resolve_mac_func(MacFunc), ++ DerivedLength = byte_size(MacFunc1(<<"test key">>, <<"test data">>)), ++ Bin = pbkdf2(MacFunc1, Password, Salt, Iterations, DerivedLength, 1, []), ++ {ok, Bin}. ++ ++%---------------------------------------------------------------------------------------------------------------------- ++ ++-spec pbkdf2(MacFunc, Password, Salt, Iterations, DerivedLength) -> {ok, Key} | {error, derived_key_too_long} when ++ MacFunc :: mac_func_info(), ++ Password :: binary(), ++ Salt :: binary(), ++ Iterations :: integer(), ++ DerivedLength :: integer(), ++ Key :: binary(). ++ ++pbkdf2(_MacFunc, _Password, _Salt, _Iterations, DerivedLength) when DerivedLength > ?MAX_DERIVED_KEY_LENGTH -> ++ {error, derived_key_too_long}; ++ ++pbkdf2(MacFunc, Password, Salt, Iterations, DerivedLength) -> ++ MacFunc1 = resolve_mac_func(MacFunc), ++ Bin = pbkdf2(MacFunc1, Password, Salt, Iterations, DerivedLength, 1, []), ++ {ok, Bin}. ++ ++%---------------------------------------------------------------------------------------------------------------------- ++ ++-spec to_hex(Data) -> HexData when ++ Data :: binary() | list(), ++ HexData :: binary() | hex_list(). ++ ++to_hex(<<>>) -> ++ <<>>; ++ ++to_hex(<>) -> ++ CharHex1 = to_hex_digit(Char div 16), ++ CharHex2 = to_hex_digit(Char rem 16), ++ RestHex = to_hex(Rest), ++ <>; ++ ++to_hex([]) -> ++ []; ++ ++to_hex([Char | Rest]) -> ++ [to_hex_digit(Char div 16), to_hex_digit(Char rem 16) | to_hex(Rest)]. ++ ++%====================================================================================================================== ++% Internal Functions ++ ++-spec pbkdf2(MacFunc, Password, Salt, Iterations, DerivedLength, BlockIndex, Acc) -> Key when ++ MacFunc :: fun((binary(), binary()) -> binary()), ++ Password :: binary(), ++ Salt :: binary(), ++ Iterations :: integer(), ++ DerivedLength :: integer(), ++ BlockIndex :: integer(), ++ Acc :: iolist(), ++ Key :: binary(). ++ ++pbkdf2(MacFunc, Password, Salt, Iterations, DerivedLength, BlockIndex, Acc) -> ++ case iolist_size(Acc) > DerivedLength of ++ true -> ++ <> = iolist_to_binary(lists:reverse(Acc)), ++ Bin; ++ false -> ++ Block = pbkdf2(MacFunc, Password, Salt, Iterations, BlockIndex, 1, <<>>, <<>>), ++ pbkdf2(MacFunc, Password, Salt, Iterations, DerivedLength, BlockIndex + 1, [Block | Acc]) ++ end. ++ ++%---------------------------------------------------------------------------------------------------------------------- ++ ++-spec pbkdf2(MacFunc, Password, Salt, Iterations, BlockIndex, Iteration, Prev, Acc) -> Key when ++ MacFunc :: fun((binary(), binary()) -> binary()), ++ Password :: binary(), ++ Salt :: binary(), ++ Iterations :: integer(), ++ BlockIndex :: integer(), ++ Iteration :: integer(), ++ Prev :: binary(), ++ Acc :: binary(), ++ Key :: binary(). ++ ++pbkdf2(_MacFunc, _Password, _Salt, Iterations, _BlockIndex, Iteration, _Prev, Acc) when Iteration > Iterations -> ++ Acc; ++ ++pbkdf2(MacFunc, Password, Salt, Iterations, BlockIndex, 1, _Prev, _Acc) -> ++ InitialBlock = MacFunc(Password, <>), ++ pbkdf2(MacFunc, Password, Salt, Iterations, BlockIndex, 2, InitialBlock, InitialBlock); ++ ++pbkdf2(MacFunc, Password, Salt, Iterations, BlockIndex, Iteration, Prev, Acc) -> ++ Next = MacFunc(Password, Prev), ++ pbkdf2(MacFunc, Password, Salt, Iterations, BlockIndex, Iteration + 1, Next, crypto:exor(Next, Acc)). ++ ++%---------------------------------------------------------------------------------------------------------------------- ++ ++%-type mac_func_info() :: mac_func() | {hmac, digest_func_info()} ++% | md4 | md5 | ripemd160 | sha | sha224 | sha256 | sha384 | sha512. ++ ++resolve_mac_func({hmac, DigestFunc}) -> ++ fun(Key, Data) -> ++ %crypto:hmac(DigestFunc, Key, Data) ++ HMAC = crypto:hmac_init(DigestFunc, Key), ++ HMAC1 = crypto:hmac_update(HMAC, Data), ++ crypto:hmac_final(HMAC1) ++ end; ++ ++resolve_mac_func(MacFunc) when is_function(MacFunc) -> ++ MacFunc; ++ ++resolve_mac_func(md4) -> resolve_mac_func({hmac, md4}); ++resolve_mac_func(md5) -> resolve_mac_func({hmac, md5}); ++resolve_mac_func(ripemd160) -> resolve_mac_func({hmac, ripemd160}); ++resolve_mac_func(sha) -> resolve_mac_func({hmac, sha}); ++resolve_mac_func(sha224) -> resolve_mac_func({hmac, sha224}); ++resolve_mac_func(sha256) -> resolve_mac_func({hmac, sha256}); ++resolve_mac_func(sha384) -> resolve_mac_func({hmac, sha384}); ++resolve_mac_func(sha512) -> resolve_mac_func({hmac, sha512}). ++ ++%---------------------------------------------------------------------------------------------------------------------- ++ ++%% Compare two strings or binaries for equality without short-circuits to avoid timing attacks. ++ ++-spec compare_secure(First, Second) -> boolean() when ++ First :: binary() | string(), ++ Second :: binary() | string(). ++ ++compare_secure(<>, <>) -> ++ compare_secure(binary_to_list(X), binary_to_list(Y)); ++ ++compare_secure(X, Y) when is_list(X) and is_list(Y) -> ++ case length(X) == length(Y) of ++ true -> ++ compare_secure(X, Y, 0); ++ false -> ++ false ++ end; ++ ++compare_secure(_X, _Y) -> false. ++ ++-spec compare_secure(First, Second, Accum) -> boolean() when ++ First :: string(), ++ Second :: string(), ++ Accum :: integer(). ++ ++compare_secure([X|RestX], [Y|RestY], Result) -> ++ compare_secure(RestX, RestY, (X bxor Y) bor Result); ++ ++compare_secure([], [], Result) -> ++ Result == 0. ++ ++%---------------------------------------------------------------------------------------------------------------------- ++ ++-spec to_hex_digit(Nyble) -> hex_char() when ++ Nyble :: 0 .. 15. ++ ++to_hex_digit(N) when N < 10 -> ++ $0 + N; ++ ++to_hex_digit(N) -> ++ $a + N - 10. +diff --git a/src/riak_core.app.src b/src/riak_core.app.src +index 4bfb03f..c5a3837 100644 +--- a/src/riak_core.app.src ++++ b/src/riak_core.app.src +@@ -17,7 +17,6 @@ + os_mon, + basho_stats, + eleveldb, +- pbkdf2, + poolboy, + exometer_core, + clique diff --git a/erlang-riak_core-0004-Use-poolboy-API-for-stopping-poolboy.patch b/erlang-riak_core-0004-Use-poolboy-API-for-stopping-poolboy.patch new file mode 100644 index 0000000..9513bd9 --- /dev/null +++ b/erlang-riak_core-0004-Use-poolboy-API-for-stopping-poolboy.patch @@ -0,0 +1,19 @@ +From: Peter Lemenkov +Date: Sat, 23 Apr 2016 11:55:45 +0300 +Subject: [PATCH] Use poolboy API for stopping poolboy + +Signed-off-by: Peter Lemenkov + +diff --git a/src/riak_core_vnode_worker_pool.erl b/src/riak_core_vnode_worker_pool.erl +index 5a56494..49aace9 100644 +--- a/src/riak_core_vnode_worker_pool.erl ++++ b/src/riak_core_vnode_worker_pool.erl +@@ -203,7 +203,7 @@ handle_info(_Info, StateName, State) -> + + terminate(_Reason, _StateName, #state{pool=Pool}) -> + %% stop poolboy +- gen_fsm:sync_send_all_state_event(Pool, stop), ++ poolboy:stop(Pool), + ok. + + code_change(_OldVsn, StateName, State, _Extra) -> diff --git a/erlang-riak_core-0005-Revert-Copy-in-mochiglobal-as-riak_core_mochiglobal.patch b/erlang-riak_core-0005-Revert-Copy-in-mochiglobal-as-riak_core_mochiglobal.patch new file mode 100644 index 0000000..58b96e3 --- /dev/null +++ b/erlang-riak_core-0005-Revert-Copy-in-mochiglobal-as-riak_core_mochiglobal.patch @@ -0,0 +1,232 @@ +From: Peter Lemenkov +Date: Sat, 23 Apr 2016 12:02:49 +0300 +Subject: [PATCH] Revert "Copy in mochiglobal as riak_core_mochiglobal." + +This reverts commit 13f894a05ad2b8e4a461e4685e8f9f044e58ae9b. + +diff --git a/src/riak_core_dtrace.erl b/src/riak_core_dtrace.erl +index 3b7208f..faaef31 100644 +--- a/src/riak_core_dtrace.erl ++++ b/src/riak_core_dtrace.erl +@@ -146,26 +146,26 @@ timeit0(ArgList) -> + end. + + timeit_mg(ArgList) -> +- case riak_core_mochiglobal:get(?MAGIC) of ++ case mochiglobal:get(?MAGIC) of + undefined -> + case application:get_env(riak_core, dtrace_support) of + {ok, true} -> + case string:to_float(erlang:system_info(version)) of + {5.8, _} -> + %% R14B04 +- riak_core_mochiglobal:put(?MAGIC, dtrace), ++ mochiglobal:put(?MAGIC, dtrace), + timeit_mg(ArgList); + {Num, _} when Num > 5.8 -> + %% R15B or higher, though dyntrace option + %% was first available in R15B01. +- riak_core_mochiglobal:put(?MAGIC, dyntrace), ++ mochiglobal:put(?MAGIC, dyntrace), + timeit_mg(ArgList); + _ -> +- riak_core_mochiglobal:put(?MAGIC, unsupported), ++ mochiglobal:put(?MAGIC, unsupported), + false + end; + _ -> +- riak_core_mochiglobal:put(?MAGIC, unsupported), ++ mochiglobal:put(?MAGIC, unsupported), + false + end; + dyntrace -> +@@ -192,7 +192,7 @@ timeit_naive_test() -> + -define(REPS, 225000). + + timeit_mochiglobal_test() -> +- riak_core_mochiglobal:delete(?MAGIC), ++ mochiglobal:delete(?MAGIC), + Reps = lists:seq(1, ?REPS), + test_common("timeit_mochiglobal", + fun() -> +@@ -201,7 +201,7 @@ timeit_mochiglobal_test() -> + [unused, {timer:now_diff(os:timestamp(), Start), unused}] + end, + ?REPS), +- riak_core_mochiglobal:delete(?MAGIC). ++ mochiglobal:delete(?MAGIC). + + timeit_best_off_test() -> + timeit_best_common("timeit_best OFF (fastest)", false). +diff --git a/src/riak_core_mochiglobal.erl b/src/riak_core_mochiglobal.erl +deleted file mode 100644 +index c7fde00..0000000 +--- a/src/riak_core_mochiglobal.erl ++++ /dev/null +@@ -1,107 +0,0 @@ +-%% @author Bob Ippolito +-%% @copyright 2010 Mochi Media, Inc. +-%% @doc Abuse module constant pools as a "read-only shared heap" (since erts 5.6) +-%% [1]. +--module(riak_core_mochiglobal). +--author("Bob Ippolito "). +--export([get/1, get/2, put/2, delete/1]). +- +--spec get(atom()) -> any() | undefined. +-%% @equiv get(K, undefined) +-get(K) -> +- get(K, undefined). +- +--spec get(atom(), T) -> any() | T. +-%% @doc Get the term for K or return Default. +-get(K, Default) -> +- get(K, Default, key_to_module(K)). +- +-get(_K, Default, Mod) -> +- try Mod:term() +- catch error:undef -> +- Default +- end. +- +--spec put(atom(), any()) -> ok. +-%% @doc Store term V at K, replaces an existing term if present. +-put(K, V) -> +- put(K, V, key_to_module(K)). +- +-put(_K, V, Mod) -> +- Bin = compile(Mod, V), +- code:purge(Mod), +- {module, Mod} = code:load_binary(Mod, atom_to_list(Mod) ++ ".erl", Bin), +- ok. +- +--spec delete(atom()) -> boolean(). +-%% @doc Delete term stored at K, no-op if non-existent. +-delete(K) -> +- delete(K, key_to_module(K)). +- +-delete(_K, Mod) -> +- code:purge(Mod), +- code:delete(Mod). +- +--spec key_to_module(atom()) -> atom(). +-key_to_module(K) -> +- list_to_atom("mochiglobal:" ++ atom_to_list(K)). +- +--spec compile(atom(), any()) -> binary(). +-compile(Module, T) -> +- {ok, Module, Bin} = compile:forms(forms(Module, T), +- [verbose, report_errors]), +- Bin. +- +--spec forms(atom(), any()) -> [erl_syntax:syntaxTree()]. +-forms(Module, T) -> +- [erl_syntax:revert(X) || X <- term_to_abstract(Module, term, T)]. +- +--spec term_to_abstract(atom(), atom(), any()) -> [erl_syntax:syntaxTree()]. +-term_to_abstract(Module, Getter, T) -> +- [%% -module(Module). +- erl_syntax:attribute( +- erl_syntax:atom(module), +- [erl_syntax:atom(Module)]), +- %% -export([Getter/0]). +- erl_syntax:attribute( +- erl_syntax:atom(export), +- [erl_syntax:list( +- [erl_syntax:arity_qualifier( +- erl_syntax:atom(Getter), +- erl_syntax:integer(0))])]), +- %% Getter() -> T. +- erl_syntax:function( +- erl_syntax:atom(Getter), +- [erl_syntax:clause([], none, [erl_syntax:abstract(T)])])]. +- +-%% +-%% Tests +-%% +--ifdef(TEST). +--include_lib("eunit/include/eunit.hrl"). +-get_put_delete_test() -> +- K = '$$test$$mochiglobal', +- delete(K), +- ?assertEqual( +- bar, +- get(K, bar)), +- try +- ?MODULE:put(K, baz), +- ?assertEqual( +- baz, +- get(K, bar)), +- ?MODULE:put(K, wibble), +- ?assertEqual( +- wibble, +- ?MODULE:get(K)) +- after +- delete(K) +- end, +- ?assertEqual( +- bar, +- get(K, bar)), +- ?assertEqual( +- undefined, +- ?MODULE:get(K)), +- ok. +--endif. +diff --git a/src/riak_core_ring_manager.erl b/src/riak_core_ring_manager.erl +index 896c4f6..ab2a16a 100644 +--- a/src/riak_core_ring_manager.erl ++++ b/src/riak_core_ring_manager.erl +@@ -121,7 +121,7 @@ start_link(test) -> + + %% @spec get_my_ring() -> {ok, riak_core_ring:riak_core_ring()} | {error, Reason} + get_my_ring() -> +- Ring = case riak_core_mochiglobal:get(?RING_KEY) of ++ Ring = case mochiglobal:get(?RING_KEY) of + ets -> + case ets:lookup(?ETS, ring) of + [{_, RingETS}] -> +@@ -542,13 +542,13 @@ cleanup_ets(test) -> + reset_ring_id() -> + %% Maintain ring id epoch using mochiglobal to ensure ring id remains + %% monotonic even if the riak_core_ring_manager crashes and restarts +- Epoch = case riak_core_mochiglobal:get(riak_ring_id_epoch) of ++ Epoch = case mochiglobal:get(riak_ring_id_epoch) of + undefined -> + 0; + Value -> + Value + end, +- riak_core_mochiglobal:put(riak_ring_id_epoch, Epoch + 1), ++ mochiglobal:put(riak_ring_id_epoch, Epoch + 1), + {Epoch + 1, 0}. + + %% Set the ring in mochiglobal/ETS. Exported during unit testing +@@ -610,17 +610,17 @@ set_ring_global(Ring) -> + {chashbin, CHBin} | BucketMeta2], + ets:insert(?ETS, Actions), + ets:match_delete(?ETS, {{bucket, '_'}, undefined}), +- case riak_core_mochiglobal:get(?RING_KEY) of ++ case mochiglobal:get(?RING_KEY) of + ets -> + ok; + _ -> +- riak_core_mochiglobal:put(?RING_KEY, ets) ++ mochiglobal:put(?RING_KEY, ets) + end, + ok. + + promote_ring() -> + {ok, Ring} = get_my_ring(), +- riak_core_mochiglobal:put(?RING_KEY, Ring). ++ mochiglobal:put(?RING_KEY, Ring). + + %% Persist a new ring file, set the global value and notify any listeners + prune_write_notify_ring(Ring, State) -> +@@ -671,7 +671,7 @@ set_ring_global_test() -> + Ring = riak_core_ring:fresh(), + set_ring_global(Ring), + promote_ring(), +- ?assert(riak_core_ring:nearly_equal(Ring, riak_core_mochiglobal:get(?RING_KEY))), ++ ?assert(riak_core_ring:nearly_equal(Ring, mochiglobal:get(?RING_KEY))), + cleanup_ets(test). + + set_my_ring_test() -> diff --git a/erlang-riak_core.spec b/erlang-riak_core.spec index 6f4bb35..48e98ec 100644 --- a/erlang-riak_core.spec +++ b/erlang-riak_core.spec @@ -1,66 +1,43 @@ %global realname riak_core %global upstream basho +# Technically, we're noarch; but erlang whose directories we install into is not. %global debug_package %{nil} -%global git_tag 5f683f5 -%global patchnumber 0 Name: erlang-%{realname} -Version: 1.3.2 -Release: 5%{?dist} +Version: 2.1.5 +Release: 1%{?dist} Summary: Distributed systems infrastructure used by Riak Group: Development/Languages License: ASL 2.0 -URL: https://github.com/basho/riak_core -# wget --content-disposition https://github.com/basho/riak_core/tarball/1.3.2 -Source0: %{upstream}-%{realname}-%{version}-%{patchnumber}-g%{git_tag}.tar.gz -# Fedora/EPEL-specific -Patch1: erlang-riak_core-0001-Fix-rebar-deps.patch -# Cherry-picked from upstream -Patch2: erlang-riak_core-0002-Fix-overload-test-time-outs.patch - -# Required for unit-tests only (if you're not interested in a compile-time -# testing then you may remove these lines): +URL: https://github.com/%{upstream}/%{realname} +%if 0%{?el7}%{?fedora} +VCS: scm:git:https://github.com/%{upstream}/%{realname}.git +%endif +Source0: https://github.com/%{upstream}/%{realname}/archive/%{version}/%{realname}-%{version}.tar.gz +# https://github.com/basho/riak_core/pull/799 +Patch1: erlang-riak_core-0001-Use-a-new-riak_core_util-unique_seed-0-function.patch +# https://github.com/basho/riak_core/pull/799 +Patch2: erlang-riak_core-0002-Fix-chashbin-record-typespec-warning.patch +# Fedora-specific +Patch3: erlang-riak_core-0003-Don-t-use-pbkdf2-as-application.patch +# https://github.com/basho/riak_core/pull/639 +Patch4: erlang-riak_core-0004-Use-poolboy-API-for-stopping-poolboy.patch +# Fedora-specific +Patch5: erlang-riak_core-0005-Revert-Copy-in-mochiglobal-as-riak_core_mochiglobal.patch BuildRequires: erlang-basho_stats >= 1.0.3 -BuildRequires: erlang-folsom +BuildRequires: erlang-clique +BuildRequires: erlang-cluster_info +BuildRequires: erlang-eleveldb +BuildRequires: erlang-exometer_core BuildRequires: erlang-lager >= 1.2.2 +BuildRequires: erlang-meck BuildRequires: erlang-mochiweb BuildRequires: erlang-poolboy >= 0.8.1 +BuildRequires: erlang-rebar +BuildRequires: erlang-riak_ensemble BuildRequires: erlang-riak_sysmon >= 1.1.3 -# Compile-time requirements -BuildRequires: erlang-meck >= 0.7.2 -BuildRequires: erlang-rebar -BuildRequires: erlang-protobuffs >= 0.8.0 -BuildRequires: erlang-webmachine >= 1.9.3 - -# Error:erlang(dtrace:put_utag/1) -Requires: erlang-basho_stats%{?_isa} -Requires: erlang-cluster_info%{?_isa} -Requires: erlang-crypto%{?_isa} -# Error:erlang(erlang:atom_to_binary/2) in R12B and below -# Error:erlang(erlang:binary_to_atom/2) in R12B and below -# Error:erlang(erlang:max/2) in R12B and below -# Error:erlang(erlang:min/2) in R12B and below -# Error:erlang(lists:keyfind/3) in R12B and below -# Error:erlang(os:timestamp/0) in R12B and below -Requires: erlang-erts%{?_isa} >= R13B -Requires: erlang-folsom%{?_isa} -Requires: erlang-inets%{?_isa} -Requires: erlang-kernel%{?_isa} -Requires: erlang-lager%{?_isa} -Requires: erlang-mochiweb%{?_isa} -Requires: erlang-poolboy%{?_isa} -Requires: erlang-protobuffs%{?_isa} -Requires: erlang-riak_sysmon%{?_isa} -# Error:erlang(dyntrace:p/0) in R14B and below -# Error:erlang(dyntrace:put_tag/1) in R14B and below -Requires: erlang-runtime_tools%{?_isa} >= R15B -# Error:erlang(ssl:ssl_accept/3) in R12B and below -Requires: erlang-ssl%{?_isa} >= R13B -# Error:erlang(supervisor:count_children/1) in R12B and below -Requires: erlang-stdlib%{?_isa} >= R13B -Requires: erlang-webmachine%{?_isa} %description @@ -68,37 +45,37 @@ Distributed systems infrastructure used by Riak. %prep -%setup -q -n %{upstream}-%{realname}-356b592 -%patch1 -p1 -b .deps -%patch2 -p1 -b .timeout +%setup -q -n %{realname}-%{version} +%patch1 -p1 -b .deprecated_bif +%patch2 -p1 -b .proper_type +%patch3 -p1 -b .no_app_for_pbkdf2 +%patch4 -p1 -b .poolboy_api +%patch5 -p1 -b .use_mochiweb %build -rebar compile -v +%{erlang_compile} %install -mkdir -p %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/{ebin,include,priv} -install -p -m 644 ebin/%{realname}.app %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/ebin -install -p -m 644 ebin/*.beam %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/ebin -install -p -m 644 include/*.hrl %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/include +%{erlang_install} +install -D -p -m 644 priv/riak_core.schema %{buildroot}%{erlang_appdir}/priv/riak_core.schema %check -rebar eunit skip_deps=true -v +%{erlang_test} %files -%doc LICENSE README.md -%dir %{_libdir}/erlang/lib/%{realname}-%{version} -%dir %{_libdir}/erlang/lib/%{realname}-%{version}/ebin -%dir %{_libdir}/erlang/lib/%{realname}-%{version}/include -%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}.app -%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/*.beam -%{_libdir}/erlang/lib/%{realname}-%{version}/include/*.hrl +%license LICENSE +%doc README.md docs/* +%{erlang_appdir}/ %changelog +* Fri Apr 22 2016 Peter Lemenkov - 2.1.5-1 +- Ver. 2.1.5 + * Wed Feb 03 2016 Fedora Release Engineering - 1.3.2-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild diff --git a/sources b/sources index bed3c5e..4db07ad 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -82ae3eeee67b1b5bcd3060dc43364202 basho-riak_core-1.3.2-0-g5f683f5.tar.gz +f25e820fcbe03db40b73fc6f872bfa5d riak_core-2.1.5.tar.gz