From e95f32231a806e91e02fd63fb7e1acd0e5aee69a Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 25 Sep 2019 16:25:20 +0000 Subject: [PATCH] fixed: FileLog::get_local_date we need to synchronize when using time_zones pointer (FileLog::get_local_date is used by Log::PrintDate() and Log of course can be used from different threads) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1218 e52654a7-88a9-db11-a3e9-0013d4bc506e --- winixd/core/filelog.cpp | 3 ++- winixd/core/log.cpp | 27 ++++++++++++++------------- winixd/core/log.h | 4 ++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/winixd/core/filelog.cpp b/winixd/core/filelog.cpp index f5844b5..717ae06 100644 --- a/winixd/core/filelog.cpp +++ b/winixd/core/filelog.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2018, Tomasz Sowa + * Copyright (c) 2018-2019, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -95,6 +95,7 @@ PT::Date FileLog::get_local_date(const PT::Date & date) { if( time_zones ) { + Lock lock(synchro); TimeZone * tz = time_zones->GetZone(log_time_zone_id); if( tz ) diff --git a/winixd/core/log.cpp b/winixd/core/log.cpp index 0abd1d5..0b22d0c 100644 --- a/winixd/core/log.cpp +++ b/winixd/core/log.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2008-2018, Tomasz Sowa + * Copyright (c) 2008-2019, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -77,7 +77,7 @@ void Log::PrintDate(const PT::Date & date) FileLog * winix_file_log = dynamic_cast(file_log); if( winix_file_log ) - (*this) << winix_file_log->get_local_date(date); + (*this) << winix_file_log->get_local_date(date); // synchronization is made in get_local_date else (*this) << date; } @@ -250,17 +250,18 @@ return *this; } -Log & Log::SystemErr(int err) -{ - (*this) << "errno: " << err; - - const char * err_msg = strerror(err); - - if( err_msg ) - (*this) << " (" << err_msg << ")"; - - return *this; -} +//Log & Log::SystemErr(int err) +//{ +// (*this) << "errno: " << err; +// +// // strerror is not thread safe and we now use Log in each thread +// const char * err_msg = strerror(err); +// +// if( err_msg ) +// (*this) << " (" << err_msg << ")"; +// +// return *this; +//} diff --git a/winixd/core/log.h b/winixd/core/log.h index ed4c20f..f016db6 100644 --- a/winixd/core/log.h +++ b/winixd/core/log.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2008-2018, Tomasz Sowa + * Copyright (c) 2008-2019, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,7 +91,7 @@ public: virtual Log & LogBinary(const char * blob, size_t blob_len); virtual Log & LogBinary(const std::string & blob); - virtual Log & SystemErr(int err); + //virtual Log & SystemErr(int err); private: