diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2018-10-09 15:25:18 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-10-22 10:07:01 +0000 |
commit | 6c543879a31d7d13a6b87e6332f6913f2f89f5e6 (patch) | |
tree | a4471a1ba1a5c89b20a0f8741f81f0729686e94e /src/corelib/global/qglobal_p.h | |
parent | a7518a11b6975e1fb1ad8584fd4f5fa6b434d839 (diff) |
Avoid races on TZ in environment via tzset() calls
POSIX specifies that tzset() consults environment variable TZ and
modifies some globals; it also specifies mktime(), localtime() and
strftime() to behave as if they called tzset(). Fortunately, we only
call strftime() from a test and only call localtime() when not
threaded. Provide wrappers for tzset() and mktime() that share the
lock used by our environment-access code, to prevent races on the
environment (and tzset()'s globals) when we call them.
In the process, re-use tst_QDateTime's TimeZoneRollback in its older
test systemTimeZoneChange() and presume that this can now be tested
cross-platform, since TimeZoneRollback is used in another test where
this works.
Fixes: QTBUG-71030
Change-Id: I79f559b8857ea2803e73501008bf0d7158c6731f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qglobal_p.h')
-rw-r--r-- | src/corelib/global/qglobal_p.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h index 0f092e9006..d52f6268e4 100644 --- a/src/corelib/global/qglobal_p.h +++ b/src/corelib/global/qglobal_p.h @@ -61,6 +61,16 @@ #endif #if defined(__cplusplus) +#include <time.h> + +QT_BEGIN_NAMESPACE + +// These behave as if they consult the environment, so need to share its locking: +Q_CORE_EXPORT void qTzSet(); +Q_CORE_EXPORT time_t qMkTime(struct tm *when); + +QT_END_NAMESPACE + #if !QT_HAS_BUILTIN(__builtin_available) #include <initializer_list> #include <QtCore/qoperatingsystemversion.h> |