Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
test:
name: "Erlang Test"
name: "OTP ${{ matrix.otp }}"
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -19,6 +19,14 @@ jobs:
container:
image: erlang:${{ matrix.otp }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Test
run: make
- name: Upload CT logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: ct-logs-otp-${{ matrix.otp }}
path: _build/test/logs
if-no-files-found: ignore
retention-days: 14
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ eqc/*.beam
*/#*#
erl_crash.dump
gproc_dist*@*
rebar.lock
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
## DEALINGS IN THE SOFTWARE.
REBAR3=$(shell which rebar3 || echo ./rebar3)

.PHONY: all compile clean eunit test doc check dialyzer
.PHONY: all compile clean eunit ct test doc check dialyzer

DIRS=src

Expand All @@ -35,10 +35,18 @@ compile:
clean:
$(REBAR3) clean

# Local / non-distributed eunit only. gproc_dist lives under CT
# (see gproc_dist_SUITE); the old dist eunit generator is disabled.
eunit:
$(REBAR3) eunit

test: eunit
# Distributed suite: locks_leader peers + per-node disk logs.
ct:
@epmd -daemon 2>/dev/null || true
$(REBAR3) ct --suite test/gproc_dist_SUITE

# Full local gate (matches intended CI split).
test: eunit ct

doc:
$(REBAR3) as edown edoc
Expand Down
5 changes: 2 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
{erl_opts, [debug_info]}.

{deps, [
{gen_leader, ".*",
{git, "https://github.com/garret-smith/gen_leader_revival.git", "HEAD"}}
{locks, {git, "https://github.com/uwiger/locks.git", {ref, "ed69e18"}}}
]}.

{dialyzer, [{plt_apps, all_deps},
{plt_extra_apps, [mnesia, runtime_tools, gen_leader]},
{plt_extra_apps, [mnesia, runtime_tools, locks]},
{warnings, [no_unused,
no_improper_lists, no_fun_app, no_match,
no_opaque, no_fail_call,
Expand Down
33 changes: 0 additions & 33 deletions rebar.config.script

This file was deleted.

12 changes: 12 additions & 0 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{"1.2.0",
[{<<"locks">>,
{git,"https://github.com/uwiger/locks.git",
{ref,"ed69e1864cc2f8a323f592ca23e3a8e792116ee9"}},
0},
{<<"plain_fsm">>,{pkg,<<"plain_fsm">>,<<"1.4.9">>},1}]}.
[
{pkg_hash,[
{<<"plain_fsm">>, <<"047B015FD70B533562DEC3FF2861E2465E67CD6F31034C5D7954B56ABBB839DD">>}]},
{pkg_hash_ext,[
{<<"plain_fsm">>, <<"A9630F78C05599E45AFCF9B423F2A30752F72A527F3C17A24F10E387BBCB91B8">>}]}
].
6 changes: 5 additions & 1 deletion src/gproc.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
{vsn, "zomp"},
{id, "GPROC"},
{registered, [ ] },
{applications, [ kernel, stdlib ] },
%% locks is optional: listed in both applications and optional_applications
%% so the app controller starts it automatically when present, but gproc
%% still loads if locks is absent (local-only installs).
{applications, [ kernel, stdlib, locks ] },
{optional_applications, [ locks ] },
{mod, {gproc_app, []} },
{licenses, ["Apache-2.0"]},
{links, [{"Github", "https://github.com/uwiger/gproc"}]}
Expand Down
15 changes: 11 additions & 4 deletions src/gproc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
%% starting the `gproc' and `gproc_dist' servers. Default is `[]'. It is
%% likely that `{priority, high | max}' and/or increasing `min_heap_size'
%% will improve performance.
%% * `{gproc_dist, all | [node()] | {[node()], list()}}' - When `locks' is
%% available and `gproc_dist' is started, an explicit node list causes
%% `net_kernel:connect_node/1' for each peer before joining the society.
%% `all' / `true' do not connect (already-connected nodes are discovered
%% via locks_pg). Under gen_leader this env also controlled whether dist
%% started; now dist starts whenever `locks' is running
%% (see optional_applications).
%%
%% @end

Expand Down Expand Up @@ -191,6 +198,7 @@
ok
end).


-define(PID_IS_DEAD(Pid),
(node(Pid) == node() andalso is_process_alive(Pid) == false)).

Expand Down Expand Up @@ -706,7 +714,6 @@ await(Node, Key, Timeout) when is_atom(Node) ->
?CATCH_GPROC_ERROR(await1(Node, Key, Timeout), [Node, Key, Timeout]).

await1({T,g,_} = Key, Timeout) when T=:=n; T=:=a; T=:=rc ->
?CHK_DIST,
request_wait(Key, Timeout);
await1({T,l,_} = Key, Timeout) when T=:=n; T=:=a; T=:=rc ->
case ets:lookup(?TAB, {Key, T}) of
Expand Down Expand Up @@ -860,7 +867,6 @@ nb_wait(Node, Key) ->
?CATCH_GPROC_ERROR(nb_wait1(Node, Key), [Node, Key]).

nb_wait1({T,g,_} = Key) when T=:=n; T=:=a; T=:=rc ->
?CHK_DIST,
call({await, Key, self()}, g);
nb_wait1({T,l,_} = Key) when T=:=n; T=:=a; T=:=rc ->
call({await, Key, self()}, l);
Expand Down Expand Up @@ -901,7 +907,6 @@ cancel_wait(N, Key, Ref) ->


cancel_wait1({_,g,_} = Key, Ref) ->
?CHK_DIST,
cast({cancel_wait, self(), Key, Ref}, g),
ok;
cancel_wait1({_,l,_} = Key, Ref) ->
Expand All @@ -917,7 +922,6 @@ cancel_wait_or_monitor(Key) ->
?CATCH_GPROC_ERROR(cancel_wait_or_monitor1(Key), [Key]).

cancel_wait_or_monitor1({_,g,_} = Key) ->
?CHK_DIST,
cast({cancel_wait_or_monitor, self(), Key}, g),
ok;
cancel_wait_or_monitor1({_,l,_} = Key) ->
Expand Down Expand Up @@ -2610,12 +2614,14 @@ call(Req) ->
call(Req, l) ->
chk_reply(gen_server:call(?MODULE, Req));
call(Req, g) ->
?CHK_DIST,
chk_reply(gproc_dist:leader_call(Req)).

call(N, Req, l) ->
chk_reply(gen_server:call({?MODULE, N}, Req));
call(undefined, Req, g) ->
%% we always call the leader
?CHK_DIST,
chk_reply(gproc_dist:leader_call(Req)).


Expand All @@ -2632,6 +2638,7 @@ cast(Msg) ->
cast(Msg, l) ->
gen_server:cast(?MODULE, Msg);
cast(Msg, g) ->
?CHK_DIST,
gproc_dist:leader_cast(Msg).

cast(N, Msg, l) ->
Expand Down
5 changes: 5 additions & 0 deletions src/gproc_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ start() ->
start(normal, []).

start(_Type, StartArgs) ->
%% locks is optional_applications: ensure_all_started(gproc) will start it
%% as a dep, but ensure_started/start(gproc) will not. Pull locks in here
%% when it is loadable so gproc_sup can start gproc_dist; ignore failure
%% when locks is not present (local-only install).
_ = application:ensure_all_started(locks),
case gproc_sup:start_link(StartArgs) of
{ok, Pid} ->
{ok, Pid};
Expand Down
Loading