aboutsummaryrefslogtreecommitdiffstats
path: root/lib/megaco/src/engine/megaco_config.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2010-06-02 23:31:23 +0000
committerErlang/OTP <[email protected]>2010-06-02 23:31:23 +0000
commit16d2e129ff59db4917b0495d914df646f62669b9 (patch)
tree5cbfeb11b19c0e48aa8d797f95566c23f67ef60b /lib/megaco/src/engine/megaco_config.erl
parent007340ead70a3867be6f65c60222a6a30afdf28c (diff)
downloadotp-16d2e129ff59db4917b0495d914df646f62669b9.tar.gz
otp-16d2e129ff59db4917b0495d914df646f62669b9.tar.bz2
otp-16d2e129ff59db4917b0495d914df646f62669b9.zip
OTP-8634: Pending counter raise condition.
Diffstat (limited to 'lib/megaco/src/engine/megaco_config.erl')
-rw-r--r--lib/megaco/src/engine/megaco_config.erl26
1 files changed, 7 insertions, 19 deletions
diff --git a/lib/megaco/src/engine/megaco_config.erl b/lib/megaco/src/engine/megaco_config.erl
index 0445f10838..6805db790d 100644
--- a/lib/megaco/src/engine/megaco_config.erl
+++ b/lib/megaco/src/engine/megaco_config.erl
@@ -628,31 +628,19 @@ incr_counter(Item, Incr) ->
end
catch
error:_ ->
+ %% Counter does not exist, so try creat it
try
begin
cre_counter(Item, Incr)
end
catch
exit:_ ->
- %% Ok, some other process got there before us,
- %% so try again
+ %% This is a raise condition.
+ %% When we tried to update the counter above, it
+ %% did not exist, but now it does...
ets:update_counter(megaco_config, Item, Incr)
end
end.
-%% incr_counter(Item, Incr) ->
-%% case (catch ets:update_counter(megaco_config, Item, Incr)) of
-%% {'EXIT', _} ->
-%% case (catch cre_counter(Item, Incr)) of
-%% {'EXIT', _} ->
-%% %% Ok, some other process got there before us,
-%% %% so try again
-%% ets:update_counter(megaco_config, Item, Incr);
-%% NewVal ->
-%% NewVal
-%% end;
-%% NewVal ->
-%% NewVal
-%% end.
cre_counter(Item, Initial) ->
case whereis(?SERVER) =:= self() of
@@ -660,8 +648,8 @@ cre_counter(Item, Initial) ->
case call({cre_counter, Item, Initial}) of
{ok, Value} ->
Value;
- Error ->
- exit(Error)
+ {error, Reason} ->
+ exit({failed_creating_counter, Item, Initial, Reason})
end;
true ->
%% Check that the counter does not already exists
@@ -671,7 +659,7 @@ cre_counter(Item, Initial) ->
ets:insert(megaco_config, {Item, Initial}),
{ok, Initial};
[_] ->
- %% Ouch, now what?
+ %% Possibly a raise condition
{error, already_exists}
end