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
| 1920 | * such info only when calling this function from serverCron() but not when |
| 1921 | * calling it from call(). */ |
| 1922 | void 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 | |
| 1941 | void checkChildrenDone(void) { |
| 1942 | int statloc = 0; |
no test coverage detected