aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2016-05-20 07:33:06 +0200
committerAnders Svensson <[email protected]>2016-05-30 08:54:41 +0200
commitebc80a66cd2251553565a2abf6d9ca23381bde22 (patch)
tree3ed873150cfbe5c500d08287ff4c7dbb9104020a /lib
parentf68a3780fbcc836c7036b55db5ee1d0447213c8f (diff)
downloadotp-ebc80a66cd2251553565a2abf6d9ca23381bde22.tar.gz
otp-ebc80a66cd2251553565a2abf6d9ca23381bde22.tar.bz2
otp-ebc80a66cd2251553565a2abf6d9ca23381bde22.zip
Remove diameter_reg bloat
Unexpected messages don't happen in practice, and no_auto_import is neither necessery nor difficult to avoid.
Diffstat (limited to 'lib')
-rw-r--r--lib/diameter/src/base/diameter_reg.erl23
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/diameter/src/base/diameter_reg.erl b/lib/diameter/src/base/diameter_reg.erl
index 7f198080ba..2f2dd7aaa4 100644
--- a/lib/diameter/src/base/diameter_reg.erl
+++ b/lib/diameter/src/base/diameter_reg.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2010-2015. All Rights Reserved.
+%% Copyright Ericsson AB 2010-2016. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -25,8 +25,6 @@
-module(diameter_reg).
-behaviour(gen_server).
--compile({no_auto_import, [monitor/2]}).
-
-export([add/1,
add_new/1,
del/1,
@@ -52,8 +50,6 @@
-export([state/0,
uptime/0]).
--include("diameter_internal.hrl").
-
-define(SERVER, ?MODULE).
-define(TABLE, ?MODULE).
@@ -211,7 +207,7 @@ init(_) ->
handle_call({add, Fun, Key, Pid}, _, S) ->
B = Fun(?TABLE, {Key, Pid}),
- monitor(B andalso no_monitor(Pid), Pid),
+ insert_monitor(B andalso no_monitor(Pid), Pid),
{reply, B, pending(B, S)};
handle_call({del, Key, Pid}, _, S) ->
@@ -237,16 +233,14 @@ handle_call(state, _, S) ->
handle_call(uptime, _, #state{id = Time} = S) ->
{reply, diameter_lib:now_diff(Time), S};
-handle_call(Req, From, S) ->
- ?UNEXPECTED([Req, From]),
+handle_call(_Req, _From, S) ->
{reply, nok, S}.
%% ----------------------------------------------------------
%% # handle_cast/2
%% ----------------------------------------------------------
-handle_cast(Msg, S)->
- ?UNEXPECTED([Msg]),
+handle_cast(_Msg, S)->
{noreply, S}.
%% ----------------------------------------------------------
@@ -258,8 +252,7 @@ handle_info({'DOWN', MRef, process, Pid, _}, S) ->
ets:match_delete(?TABLE, ?MAPPING('_', Pid)),
{noreply, S};
-handle_info(Info, S) ->
- ?UNEXPECTED([Info]),
+handle_info(_Info, S) ->
{noreply, S}.
%% ----------------------------------------------------------
@@ -278,10 +271,8 @@ code_change(_OldVsn, State, _Extra) ->
%% ===========================================================================
-monitor(true, Pid) ->
- ets:insert(?TABLE, ?MONITOR(Pid, erlang:monitor(process, Pid)));
-monitor(false, _) ->
- ok.
+insert_monitor(B, Pid) ->
+ B andalso ets:insert(?TABLE, ?MONITOR(Pid, monitor(process, Pid))).
%% Do we need a monitor for the specified Pid?
no_monitor(Pid) ->