On Fri, Jun 5, 2009 at 10:05 AM, Soeren.Meyer-Eppler<[email protected]> wrote: >> SOCI behavior is incorrect. It's non-trivial to implement the correct >> behavior in a thread-safe and portable way. We discussed it on >> soci-devel and at the time decided to ignore the issue until some user >> hits it. I guess now would be a good time to revisit it. > > My current hack is to call setlocale( "C" ) in the SQLite backend and > resetting to the original locale afterwards. I guess this has the > concurrency issues you are talking about. The alternative would be to > use a std::stringstream with a locale imbued. That should do the trick - no?
On many platforms (including Mac OS X, FreeBSD and Linux with glibc 2.2 or older) the standard stream library uses setlocale() internally for changing locales. Check out the first few results for http://www.google.com/codesearch?hl=en&lr=&q=file%3Ac\%2B\%2Blocale\.h or search for a file named c++locale.h on your machine. So that's not thread-safe at all. Linux with glibc newer than 2.2 uses uselocale() which is thread-safe. My suggestion would be to use the same method Google's protocol buffers code uses: http://www.google.com/codesearch?hl=en&lr=&q=NoLocaleStrtod+DelocalizeRadix+package%3Aprotobuf\.googlecode\.com Admittedly it's hideous but it works correctly. Thanks, Aleksander ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Soci-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/soci-users
