Bug 13931 - Reload nscd cache entry even if its timeout is equal to the current time
Summary: Reload nscd cache entry even if its timeout is equal to the current time
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: nscd (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-30 10:52 UTC by Siddhesh Poyarekar
Modified: 2018-02-02 11:45 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Siddhesh Poyarekar 2012-03-30 10:52:25 UTC
With the current implementation of cache expiry, the timer for expiry
is set exactly at the timeout value of an entry. As a result, there is often a case where the cache prune is called at exactly the timeout time, causing the prune_cache code to think that the timeout has not occurred yet. As a result, the entry is not invalidated or reloaded until the next prune cycle, which is at least 15 seconds away. Fix is to mark an entry as timed out even when the time that prune_cache is called is exactly equal to the timeout time of the entry.
Comment 1 Siddhesh Poyarekar 2012-03-30 11:10:25 UTC
Sorry, forgot to put in steps to reproduce:

1) Add an entry in dns server that expires in 15 seconds

ad.foo.net. 15 A 10.0.0.10

2) Start nscd with debug level > 2 in nscd.conf
3) getent hosts ad.foo.net

Actual Results:

Logs look like this:

Fri 30 Mar 2012 04:37:18 PM IST - 19240: handle_request: request received (Version = 2) from PID 19256
Fri 30 Mar 2012 04:37:18 PM IST - 19240: 	GETAI (ad.foo.net)
Fri 30 Mar 2012 04:37:18 PM IST - 19240: Haven't found "ad.foo.net" in hosts cache!
Fri 30 Mar 2012 04:37:18 PM IST - 19240: add new entry "ad.foo.net" of type GETAI for hosts to cache (first)
Fri 30 Mar 2012 04:37:33 PM IST - 19240: pruning hosts cache; time 1333105653
Fri 30 Mar 2012 04:37:33 PM IST - 19240: considering GETAI entry "ad.foo.net", timeout 1333105653
Fri 30 Mar 2012 04:37:48 PM IST - 19240: pruning hosts cache; time 1333105668
Fri 30 Mar 2012 04:37:48 PM IST - 19240: considering GETAI entry "ad.foo.net", timeout 1333105653
Fri 30 Mar 2012 04:37:48 PM IST - 19240: Reloading "ad.foo.net" in hosts cache!


Expected Results:

Logs should look like this:

Logs look like this:

Fri 30 Mar 2012 04:37:18 PM IST - 19240: handle_request: request received (Version = 2) from PID 19256
Fri 30 Mar 2012 04:37:18 PM IST - 19240: 	GETAI (ad.foo.net)
Fri 30 Mar 2012 04:37:18 PM IST - 19240: Haven't found "ad.foo.net" in hosts cache!
Fri 30 Mar 2012 04:37:18 PM IST - 19240: add new entry "ad.foo.net" of type GETAI for hosts to cache (first)
Fri 30 Mar 2012 04:37:33 PM IST - 19240: pruning hosts cache; time 1333105653
Fri 30 Mar 2012 04:37:33 PM IST - 19240: considering GETAI entry "ad.foo.net", timeout 1333105653
Fri 30 Mar 2012 04:37:33 PM IST - 19240: Reloading "ad.foo.net" in hosts cache!
Comment 2 Florian Weimer 2018-02-02 11:45:42 UTC
Should invalidation be independent of the prune cycle?  That is, if the TTL expired, the entry will no longer be used?