Use context mutex to provide thread-safe time
| 1026 | |
| 1027 | // Use context mutex to provide thread-safe time |
| 1028 | cmsBool _cmsGetTime(struct tm* ptr_time) |
| 1029 | { |
| 1030 | struct tm* t; |
| 1031 | #if defined(HAVE_GMTIME_R) || defined(HAVE_GMTIME_S) |
| 1032 | struct tm tm; |
| 1033 | #endif |
| 1034 | |
| 1035 | time_t now = time(NULL); |
| 1036 | |
| 1037 | #ifdef HAVE_GMTIME_R |
| 1038 | t = gmtime_r(&now, &tm); |
| 1039 | #elif defined(HAVE_GMTIME_S) |
| 1040 | t = gmtime_s(&tm, &now) == 0 ? &tm : NULL; |
| 1041 | #else |
| 1042 | if (!InitContextMutex()) return FALSE; |
| 1043 | |
| 1044 | _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex); |
| 1045 | t = gmtime(&now); |
| 1046 | _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex); |
| 1047 | #endif |
| 1048 | |
| 1049 | if (t == NULL) |
| 1050 | return FALSE; |
| 1051 | else { |
| 1052 | *ptr_time = *t; |
| 1053 | return TRUE; |
| 1054 | } |
| 1055 | } |
no test coverage detected