- Submodule RDS contains modified content
- diff --git a/RDS/Rds/RdsLib/RdsReal.cpp b/RDS/Rds/RdsLib/RdsReal.cpp
- index c8f28b2..8c33b42 100755
- --- a/RDS/Rds/RdsLib/RdsReal.cpp
- +++ b/RDS/Rds/RdsLib/RdsReal.cpp
- @@ -44,6 +44,8 @@
- #include "RdsClientLocal.h"
- #include "DExtMath.hpp"
- +#include <locale.h>
- +
- #define RINLINE
- @@ -1539,10 +1541,24 @@ RINLINE T_Bool C_RdsUnit::readUnitSizeFile(const string &_path)
- {
- T_Bool isOK = true;
- - char savedLocale[32];
- - /* Get the name of the current locale. */
- - strncpy(savedLocale, setlocale (LC_NUMERIC, NULL), 32);
- - setlocale(LC_NUMERIC, "C");
- + locale_t saved_locale;
- + locale_t posix_locale;
- + int saved_errno;
- +
- + posix_locale = newlocale(LC_ALL_MASK, "POSIX", (locale_t)0);
- + if (posix_locale == (locale_t)0) {
- + saved_errno = errno;
- + stringstream errorMsg(stringstream::out);
- + errorMsg << "C_RdsUnit::readUnitSizeFile: newlocale(POSIX) failed with errno=" << saved_errno << ".\n";
- + poSuRdsError->errorLog (errorMsg.str().c_str());
- + return(false);
- + }
- +
- + /*
- + * Use POSIX locale because the code below uses functions which
- + * parse floating-poing values using locale-specific functions
- + */
- + saved_locale = uselocale(posix_locale);
- string completeFileName(SIZE_AND_UNIT_DIR);
- if ( !_path.empty() )
- @@ -1617,7 +1633,10 @@ RINLINE T_Bool C_RdsUnit::readUnitSizeFile(const string &_path)
- poSuRdsError->perrorLog (errorMsg.str().c_str());
- isOK = false;
- } // end else !inStream
- - setlocale(LC_NUMERIC, savedLocale);
- +
- + (void)uselocale(saved_locale);
- + freelocale(posix_locale);
- +
- return(isOK);
- } // end of method C_RdsUnit::readUnitSizeFile
RDE: Fix hang in RDS code due to setlocale() abuse in multithreaded application
Posted by Anonymous on Fri 28th Apr 2023 13:11
raw | new post
view followups (newest first): RDE: Fix hang in RDS code due to setlocale() abuse in multithreaded application by Anonymous
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.