From 885fac795b9898b5cf3994ddbaf3b6f5e2e018f3 Mon Sep 17 00:00:00 2001 From: Shunichi Shinohara Date: Wed, 9 Sep 2015 14:38:58 +0900 Subject: [PATCH 1/4] Update lager to 2.2.0 --- rebar.config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rebar.config b/rebar.config index e49632a..89c6b43 100644 --- a/rebar.config +++ b/rebar.config @@ -1,6 +1,6 @@ {sub_dirs, ["rel"]}. -{require_otp_vsn, "R14B0[234]|R15|R16"}. +{require_otp_vsn, "R16|17"}. {cover_enabled, true}. @@ -14,12 +14,12 @@ {reset_after_eunit, true}. {deps, [ + {lager, ".*", {git, "git://github.com/basho/lager", {tag, "2.2.0"}}}, + {lager_syslog, ".*", {git, "git://github.com/basho/lager_syslog", {tag, "2.1.1"}}}, {cuttlefish, ".*", {git, "git://github.com/basho/cuttlefish", {tag, "2.0.4"}}}, {node_package, ".*", {git, "git://github.com/basho/node_package", {tag, "2.0.3"}}}, {webmachine, "1.10.*", {git, "git://github.com/basho/webmachine", {tag, "1.10.8"}}}, {riakc, ".*", {git, "git://github.com/basho/riak-erlang-client", {tag, "2.1.1"}}}, - {lager, ".*", {git, "git://github.com/basho/lager", {tag, "2.1.1"}}}, - {lager_syslog, ".*", {git, "git://github.com/basho/lager_syslog", {tag, "2.1.1"}}}, {exometer_core, ".*", {git, "git://github.com/Feuerlabs/exometer_core", {tag, "1.2"}}}, {eper, ".*", {git, "git://github.com/basho/eper.git", "0.92-basho1"}} ]}. From 7fec41a546628139b00d63bb3797df16af529a27 Mon Sep 17 00:00:00 2001 From: Shunichi Shinohara Date: Wed, 9 Sep 2015 14:39:18 +0900 Subject: [PATCH 2/4] Remove old style hash support --- rebar.config.script | 12 ------------ src/stanchion_utils.erl | 9 --------- 2 files changed, 21 deletions(-) delete mode 100644 rebar.config.script diff --git a/rebar.config.script b/rebar.config.script deleted file mode 100644 index 58f42a8..0000000 --- a/rebar.config.script +++ /dev/null @@ -1,12 +0,0 @@ -case erlang:system_info(otp_release) < "R16" of - true -> - CONFIG; - false -> - HashDefine = [{d,new_hash}], - case lists:keysearch(erl_opts, 1, CONFIG) of - {value, {erl_opts, Opts}} -> - lists:keyreplace(erl_opts,1,CONFIG,{erl_opts,Opts++HashDefine}); - false -> - CONFIG ++ [{erl_opts, HashDefine}] - end -end. diff --git a/src/stanchion_utils.erl b/src/stanchion_utils.erl index c868ca4..8da399e 100644 --- a/src/stanchion_utils.erl +++ b/src/stanchion_utils.erl @@ -386,20 +386,11 @@ update_user(KeyId, UserFields) -> end. --ifdef(new_hash). sha_mac(KeyData, STS) -> crypto:hmac(sha, KeyData, STS). md5(Bin) -> crypto:hash(md5, Bin). --else. -sha_mac(KeyData, STS) -> - crypto:sha_mac(KeyData, STS). - -md5(Bin) -> - crypto:md5(Bin). --endif. - %% =================================================================== %% Internal functions From 6a740e2ed184e9c09361c65ee2fc7759f760700e Mon Sep 17 00:00:00 2001 From: Shunichi Shinohara Date: Wed, 9 Sep 2015 15:16:45 +0900 Subject: [PATCH 3/4] Add OTP 17 compatibility --- rebar.config | 5 ++++- src/stanchion_utils.erl | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/rebar.config b/rebar.config index 89c6b43..8256094 100644 --- a/rebar.config +++ b/rebar.config @@ -6,7 +6,10 @@ {lib_dirs, ["deps", "apps"]}. -{erl_opts, [debug_info, warnings_as_errors, {parse_transform, lager_transform}]}. +{erl_opts, [debug_info, + warnings_as_errors, + {parse_transform, lager_transform}, + {platform_define, "^[0-9]+", namespaced_types}]}. {xref_checks, []}. {xref_queries, [{"(XC - UC) || (XU - X - B)", []}]}. diff --git a/src/stanchion_utils.erl b/src/stanchion_utils.erl index 8da399e..20529c5 100644 --- a/src/stanchion_utils.erl +++ b/src/stanchion_utils.erl @@ -61,6 +61,12 @@ -type bucket_op_options() :: [bucket_op_option()]. -type bucket_op_option() :: {acl, acl()} | {policy, binary()} | delete_policy | {bag, binary()}. +-ifdef(namespaced_types). +-type dictionary() :: dict:dict(). +-else. +-type dictionary() :: dict(). +-endif. + %% =================================================================== %% Public API %% =================================================================== @@ -199,7 +205,7 @@ get_manifests(RiakcPid, Bucket, Key) -> end. %% @doc Determine if a set of contents of a riak object has a tombstone. --spec has_tombstone({dict(), binary()}) -> boolean(). +-spec has_tombstone({dictionary(), binary()}) -> boolean(). has_tombstone({_, <<>>}) -> true; has_tombstone({MD, _V}) -> @@ -257,7 +263,7 @@ put_bucket(BucketObj, OwnerId, Opts, RiakPid) -> stanchion_stats:update([riakc, put_cs_bucket], TAT), Result. --spec make_new_metadata(dict(), bucket_op_options()) -> dict(). +-spec make_new_metadata(dictionary(), bucket_op_options()) -> dictionary(). make_new_metadata(MD, Opts) -> MetaVals = dict:fetch(?MD_USERMETA, MD), UserMetaData = make_new_user_metadata(MetaVals, Opts), From 6a31e48ab98e44bb4f074f4e9ee226dd25274d87 Mon Sep 17 00:00:00 2001 From: Shunichi Shinohara Date: Wed, 9 Sep 2015 15:17:57 +0900 Subject: [PATCH 4/4] Fix variable collision by using same macro twice in single function frame Thanks OTP 17 compiler for finding this bug. Fantastic. --- src/stanchion_utils.erl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/stanchion_utils.erl b/src/stanchion_utils.erl index 20529c5..0a7f7b8 100644 --- a/src/stanchion_utils.erl +++ b/src/stanchion_utils.erl @@ -812,16 +812,18 @@ fetch_user(Key, RiakPid) -> {ok, Obj} -> {ok, {Obj, true}}; {error, _} -> - WeakOptions = [{r, quorum}, {pr, one}, {notfound_ok, false}], - - {Res1, TAT1} = ?TURNAROUND_TIME(riakc_pb_socket:get(RiakPid, ?USER_BUCKET, Key, WeakOptions)), - stanchion_stats:update([riakc, get_user], TAT1), - case Res1 of - {ok, Obj} -> - {ok, {Obj, false}}; - {error, Reason} -> - {error, Reason} - end + weak_fetch_user(Key, RiakPid) + end. + +weak_fetch_user(Key, RiakPid) -> + WeakOptions = [{r, quorum}, {pr, one}, {notfound_ok, false}], + {Res, TAT} = ?TURNAROUND_TIME(riakc_pb_socket:get(RiakPid, ?USER_BUCKET, Key, WeakOptions)), + stanchion_stats:update([riakc, get_user], TAT), + case Res of + {ok, Obj} -> + {ok, {Obj, false}}; + {error, Reason} -> + {error, Reason} end. %% @doc Resolve the set of buckets for a user when