2
%% <year>1999-2007</year>
3
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
17
%% The Initial Developer of the Original Code is Ericsson AB.
20
21
%%-----------------------------------------------------------------
99
100
%% process_flag(trap_exit, true),
100
101
?tcp_debug(Arg, "tcp connection handler starting", [self()]),
102
%% info_msg("starting with"
103
%% "~n Arg: ~p", [Arg]),
185
188
receive_message(Mod, RH, SendHandle, Length, Msg) ->
186
189
Opts = [link , {min_heap_size, ?HEAP_SIZE(Length)}],
187
190
spawn_opt(?MODULE, handle_received_message,
188
[Mod, RH, self(), SendHandle, Msg], Opts),
191
[Mod, RH, self(), SendHandle, Msg], Opts),
199
202
%% Func: terminate/2
200
203
%% Description: Termination function for the generic server
201
204
%%-----------------------------------------------------------------
205
terminate(shutdown = _Reason, TcpRec) ->
206
?tcp_debug(TcpRec, "tcp connection handler terminating", [self(),_Reason]),
202
209
terminate(Reason, TcpRec) ->
203
?tcp_debug(TcpRec, "tcp connection handler terminating", [self(),Reason]),
210
?tcp_debug(TcpRec, "tcp connection handler terminating", [self(), Reason]),
211
SchedId = erlang:system_info(scheduler_id),
212
SchedNum = erlang:system_info(schedulers),
213
ProcCount = erlang:system_info(process_count),
214
ProcLimit = erlang:system_info(process_limit),
215
ProcMemUsed = erlang:memory(processes_used),
216
ProcMemAlloc = erlang:memory(processes),
217
MemTot = erlang:memory(total),
218
error_msg("abormal termination: "
219
"~n Scheduler id: ~p"
220
"~n Num scheduler: ~p"
221
"~n Process count: ~p"
222
"~n Process limit: ~p"
223
"~n Memory used by erlang processes: ~p"
224
"~n Memory allocated by erlang processes: ~p"
225
"~n The total amount of memory allocated: ~p"
227
[SchedId, SchedNum, ProcCount, ProcLimit,
228
ProcMemUsed, ProcMemAlloc, MemTot, Reason]),
235
260
ets:update_counter(megaco_tcp_stats, Key, Inc).
239
% ?megaco_info("TCP connection handler " ++ F", A)).
264
%% ?megaco_info("TCP connection handler " ++ F, A).
241
266
warning_msg(F, A) ->
242
267
?megaco_warning("TCP connection handler: " ++ F, A).