MCPcopy Create free account
hub / github.com/F-Stack/f-stack / updateCachedTime

Function updateCachedTime

app/redis-6.2.6/src/server.c:1922–1939  ·  view source on GitHub ↗

We take a cached value of the unix time in the global state because with * virtual memory and aging there is to store the current time in objects at * every object access, and accuracy is not needed. To access a global var is * a lot faster than calling time(NULL). * * This function should be fast because it is called at every command execution * in call(), so it is possible to decide if to

Source from the content-addressed store, hash-verified

1920 * such info only when calling this function from serverCron() but not when
1921 * calling it from call(). */
1922void updateCachedTime(int update_daylight_info) {
1923 server.ustime = ustime();
1924 server.mstime = server.ustime / 1000;
1925 time_t unixtime = server.mstime / 1000;
1926 atomicSet(server.unixtime, unixtime);
1927
1928 /* To get information about daylight saving time, we need to call
1929 * localtime_r and cache the result. However calling localtime_r in this
1930 * context is safe since we will never fork() while here, in the main
1931 * thread. The logging function will call a thread safe version of
1932 * localtime that has no locks. */
1933 if (update_daylight_info) {
1934 struct tm tm;
1935 time_t ut = server.unixtime;
1936 localtime_r(&ut,&tm);
1937 server.daylight_active = tm.tm_isdst;
1938 }
1939}
1940
1941void checkChildrenDone(void) {
1942 int statloc = 0;

Callers 6

serverCronFunction · 0.85
blockingOperationStartsFunction · 0.85
initServerConfigFunction · 0.85
callFunction · 0.85

Calls 1

ustimeFunction · 0.70

Tested by

no test coverage detected