aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-02-06 17:15:05 +0100
committerSverker Eriksson <[email protected]>2014-02-19 17:20:05 +0100
commit5006a54b032a82ad55f33e532e4068c34fe143a9 (patch)
treed21babce3f88e24915205e0011b4451645d61de0 /lib
parentfdcdaca338849d7f63d4300e489318f6ee275d82 (diff)
downloadotp-5006a54b032a82ad55f33e532e4068c34fe143a9.tar.gz
otp-5006a54b032a82ad55f33e532e4068c34fe143a9.tar.bz2
otp-5006a54b032a82ad55f33e532e4068c34fe143a9.zip
erts: Fix race bug in ets:all/0
causing recently created/deleted tables to not be included/excluded.
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/doc/src/ets.xml6
-rw-r--r--lib/stdlib/test/ets_SUITE.erl18
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml
index 21cf8e4149..3df24bf688 100644
--- a/lib/stdlib/doc/src/ets.xml
+++ b/lib/stdlib/doc/src/ets.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1996</year><year>2013</year>
+ <year>1996</year><year>2014</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -171,6 +171,10 @@
<p>Returns a list of all tables at the node. Named tables are
given by their names, unnamed tables are given by their
table identifiers.</p>
+ <p>There is no guarantee of consistency in the returned list. Tables created
+ or deleted by other processes "during" the ets:all() call may or may
+ not be included in the list. Only tables created/deleted <em>before</em>
+ ets:all() is called are guaranteed to be included/excluded.</p>
</desc>
</func>
<func>
diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl
index 82c3e7ecaf..8dc8b2c291 100644
--- a/lib/stdlib/test/ets_SUITE.erl
+++ b/lib/stdlib/test/ets_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -75,6 +75,7 @@
-export([otp_9932/1]).
-export([otp_9423/1]).
-export([otp_10182/1]).
+-export([ets_all/1]).
-export([memory_check_summary/1]).
-export([init_per_testcase/2, end_per_testcase/2]).
@@ -151,6 +152,7 @@ all() ->
otp_10182,
otp_9932,
otp_9423,
+ ets_all,
memory_check_summary]. % MUST BE LAST
@@ -5565,7 +5567,19 @@ otp_10182(Config) when is_list(Config) ->
ets:delete(Db),
In = Out.
-
+%% Test that ets:all include/exclude tables that we know are created/deleted
+ets_all(Config) when is_list(Config) ->
+ Pids = [spawn_link(fun() -> ets_all_run() end) || _ <- [1,2]],
+ receive after 3*1000 -> ok end,
+ [begin unlink(P), exit(P,kill) end || P <- Pids],
+ ok.
+
+ets_all_run() ->
+ Table = ets:new(undefined, []),
+ true = lists:member(Table, ets:all()),
+ ets:delete(Table),
+ false = lists:member(Table, ets:all()),
+ ets_all_run().
%