File 0210-Reset-inet_db-timer-even-if-file-is-up-to-date.patch of Package erlang

From 452703a85afd397b3850e741c09d237ace44dd7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Valim?= <jose.valim@dashbit.co>
Date: Tue, 3 Nov 2020 13:32:32 +0100
Subject: [PATCH] Reset inet_db timer even if file is up to date

Prior to this patch, if 5 seconds passed and
the resolv_conf or hosts_file were up to date,
we would continue to check for the file update
on every inet_res or inet_hosts operation.

This PR makes sure that the timer is updated
even if the file is up to date, so we check
again only in the next 5 seconds.
---
 lib/kernel/src/inet_db.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/kernel/src/inet_db.erl b/lib/kernel/src/inet_db.erl
index 814c3f4276..e42856dd08 100644
--- a/lib/kernel/src/inet_db.erl
+++ b/lib/kernel/src/inet_db.erl
@@ -1214,6 +1214,8 @@ handle_set_file(ParseFun, File, Bin, From, State) ->
 
 handle_update_file(
   Finfo, File, TagTm, TagInfo, ParseFun, From, #state{db = Db} = State) ->
+    ets:insert(Db, {TagTm, times()}),
+
     %%
     %% Update file content if file has been updated
     %%
@@ -1224,7 +1226,6 @@ handle_update_file(
         {ok, Finfo_1} ->
             %% File updated - read content
             ets:insert(Db, {TagInfo, Finfo_1}),
-            ets:insert(Db, {TagTm, times()}),
             Bin =
                 case erl_prim_loader:get_file(File) of
                     {ok, B, _} -> B;
@@ -1234,7 +1235,6 @@ handle_update_file(
         _ ->
             %% No file - clear content and reset monitor
             ets:insert(Db, {TagInfo, undefined}),
-            ets:insert(Db, {TagTm, times()}),
             handle_set_file(ParseFun, File, <<>>, From, State)
     end.
 
-- 
2.26.2

openSUSE Build Service is sponsored by