Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes a race condition in which slots is called before the module is …

…started
  • Loading branch information...
commit e5d2384ed8dad8d46a8d84b89fbf3ddefdc086aa 1 parent 7f87335
@mmzeeman mmzeeman authored
Showing with 15 additions and 12 deletions.
  1. +15 −12 modules/mod_signal/mod_signal.erl
View
27 modules/mod_signal/mod_signal.erl
@@ -107,20 +107,23 @@ slots(Signal, Context) ->
Table = slot_table_name(Context),
SignalType = signal_type(Signal),
- % collect the tags
- Tags = ets:lookup(Table, SignalType),
-
- % Get the list of keys we have to
- Keys = [key(Signal, Tag) || {tags, _S, Tag} <- Tags],
+ case ets:info(Table, size) of
+ undefined -> []; %% No table, no slots.
+ _ ->
+ Tags = ets:lookup(Table, SignalType),
- slots1([], Table, Keys).
+ % Get the list of keys we have to
+ Keys = [key(Signal, Tag) || {tags, _S, Tag} <- Tags],
+
+ slots1([], Table, Keys)
+ end.
- slots1(Slots, _Table, []) ->
- [Slot || {slot, _K, Slot} <- lists:flatten(Slots)];
- slots1(Slots, Table, [undefined|T]) ->
- slots1(Slots, Table, T);
- slots1(Slots, Table, [H|T]) ->
- slots1([ets:lookup(Table, H) | Slots], Table, T).
+slots1(Slots, _Table, []) ->
+ [Slot || {slot, _K, Slot} <- lists:flatten(Slots)];
+slots1(Slots, Table, [undefined|T]) ->
+ slots1(Slots, Table, T);
+slots1(Slots, Table, [H|T]) ->
+ slots1([ets:lookup(Table, H) | Slots], Table, T).
% @doc Return how many items there
%
Please sign in to comment.
Something went wrong with that request. Please try again.