Skip to content
  • Eric S. Raymond's avatar
    Eliminate the ugly and dangerous global time-function pointer. · 1815910a
    Eric S. Raymond authored
    This is a refactoring step; no behavior changes, and all unit tests pass.
    But the way the pivot date used by various calendar functions is set is
    changed.  Used to be the pivot-setting operation was snuck in through the
    back door using a global pointer to a time-setting function; if the pointer was
    NULL various individual functions would call time(NULL). The reason for this
    ugly hack was so time could be frozen in test jigs.
    
    The new logic generates a pivot value as far up the call stack as possible
    and passes it to where it's needed.  There is one exception to this, in
    libntp/prettydate.c, where a module static pivot is set by a new initialization
    function; this needs to be called in ntpd's initialization logic.
    1815910a