From 1132117b38cfe33e770a0d5b1a782d48667427c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erland=20Sch=C3=B6nbeck?= Date: Thu, 5 Mar 2015 13:37:16 +0100 Subject: Use new time API and be back-compatible in inets Remove unused functions and removed redundant test --- lib/inets/src/tftp/tftp_logger.erl | 10 ++++++++-- lib/inets/src/tftp/tftp_sup.erl | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/inets/src/tftp') diff --git a/lib/inets/src/tftp/tftp_logger.erl b/lib/inets/src/tftp/tftp_logger.erl index 0c3620e665..aa449682ce 100644 --- a/lib/inets/src/tftp/tftp_logger.erl +++ b/lib/inets/src/tftp/tftp_logger.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. +%% Copyright Ericsson AB 2008-2015. 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 @@ -84,7 +84,13 @@ info_msg(Format, Data) -> %%------------------------------------------------------------------- add_timestamp(Format, Data) -> - Now = {_MegaSecs, _Secs, _MicroSecs} = erlang:now(), + %% Adapt to new OTP 18 erlang time API and be back-compatible + Now = try + erlang:timestamp() + catch + error:undef -> + erlang:now() + end, {{_Y, _Mo, _D}, {H, Mi, S}} = calendar:now_to_universal_time(Now), %% {"~p-~s-~sT~s:~s:~sZ,~6.6.0w tftp: " ++ Format ++ "\n", %% [Y, t(Mo), t(D), t(H), t(Mi), t(S), MicroSecs | Data]}. diff --git a/lib/inets/src/tftp/tftp_sup.erl b/lib/inets/src/tftp/tftp_sup.erl index 1cafcc1069..54806bd432 100644 --- a/lib/inets/src/tftp/tftp_sup.erl +++ b/lib/inets/src/tftp/tftp_sup.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% Copyright Ericsson AB 2005-2015. 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 @@ -93,7 +93,17 @@ unique_name(Options) -> {value, {_, Port}} when is_integer(Port), Port > 0 -> {tftpd, Port}; _ -> - {tftpd, erlang:now()} + {tftpd, unique_integer()} + end. + +unique_integer() -> + %% Adapt to OTP 18 erlang time API and be back-compatible + try + erlang:unique_integer([positive]) + catch + error:undef -> + {MS, S, US} = erlang:now(), + (MS*1000000+S)*1000000+US end. default_kill_after() -> -- cgit v1.2.3