]> git.pond.sub.org Git - empserver/commit
Make news item merging deterministic and safe for year 2038
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 27 Dec 2012 13:43:43 +0000 (14:43 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 8 May 2013 04:55:19 +0000 (06:55 +0200)
commit5738e399c4a3271b7bb7cf82eb7c595a7647d3ca
tree50fb41f2d2238d3e1b8b154a69235300048dd70b
parente9fdc200e4da89cc83c83357c9218e26714ca147
Make news item merging deterministic and safe for year 2038

News reporting merges news items into recent items with same contents.
For that purpuse, we keep a small cache of recent items.  When a new
item can't be merged into an item in the cache, the oldest item gets
evicted to make space for the new one.

ncache() evicts the first item with the smallest timestamp (struct
nwsstr member nws_when).  Timestamps are in seconds, therefore clashes
are common, and eviction depends on exact timing.  Such indeterminism
can make the smoke test fail.

Moreover, ncache() assumes timestamps cannot exceed 0x7fffffff.  If
they do, it always evicts the slot 0.  They will in 2038.

Fix by evicting round robin.  This always evicts the oldest item.
src/lib/subs/nreport.c