Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 90776 invoked from network); 14 Sep 2007 18:04:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Sep 2007 18:04:04 -0000 Received: (qmail 59384 invoked by uid 500); 14 Sep 2007 18:03:57 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 59366 invoked by uid 500); 14 Sep 2007 18:03:57 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 59355 invoked by uid 99); 14 Sep 2007 18:03:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Sep 2007 11:03:57 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.quovadx.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Sep 2007 18:03:55 +0000 Received: from qxvcexch01.ad.quovadx.com ([192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.6) with ESMTP id l8EI3Xbh019102 for ; Fri, 14 Sep 2007 18:03:33 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 14 Sep 2007 12:02:33 -0600 Message-ID: <46EACCF5.7010402@roguewave.com> Date: Fri, 14 Sep 2007 12:03:33 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4 MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: [PATCH] std::messages thread safety References: <7BDB2168BEAEF14C98F1901FD2DE6438F57A7C@epmsa009.minsk.epam.com> In-Reply-To: <7BDB2168BEAEF14C98F1901FD2DE6438F57A7C@epmsa009.minsk.epam.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 14 Sep 2007 18:02:33.0109 (UTC) FILETIME=[6C81E450:01C7F6F9] X-Virus-Checked: Checked by ClamAV on apache.org Farid Zaripov wrote: > The 22.locale.messages.cpp test fails due to using incorrect > guard type in functions from messages.cpp file. There used > _RWSTD_MT_STATIC_GUARD(), so that the functions are protected > from working simultaneously with itself only. But from every that > functions invoked __rw_manage_cat_data() which working with > shared global repository of open catalogs. _RWSTD_MT_STATIC_GUARD() lock a static local mutex, which guards the rest of the block from being entered by more than 1 thread across the whole process. AFAIK, catopen() and catgets() are not required to be thread safe so we need to guard calls to them across all instances of the facet. Maybe the problem is somewhere else? With the static mutex maybe? Martin > > The proposed patch: > > ChangeLog: > * messages.cpp (__rw_cat_open): Use _RWSTD_MT_CLASS_GUARD instead of > _RWSTD_MT_STATIC_GUARD to synchronize acces to global repository of > open > catalogs. > (__rw_get_message): Ditto. > (__rw_get_locale): Ditto. > (__rw_cat_close): Ditto. > > Index: messages.cpp > =================================================================== > --- messages.cpp (revision 575597) > +++ messages.cpp (working copy) > @@ -213,7 +213,7 @@ > int > __rw_cat_open (const _STD::string &cat_name, const _STD::locale &loc) > { > - _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); > + _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data); > > const nl_catd catd = catopen (cat_name.c_str (), NL_CAT_LOCALE); > if (_RWSTD_BAD_CATD == catd) > @@ -239,7 +239,7 @@ > if (cat < 0) > return 0; > > - _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); > + _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data); > > __rw_open_cat_data *const pcat_data = __rw_manage_cat_data (cat, > 0); > > @@ -264,7 +264,7 @@ > const _STD::locale& > __rw_get_locale (int cat) > { > - _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); > + _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data); > > _RWSTD_ASSERT (0 <= cat); > __rw_open_cat_data* const pcat_data = __rw_manage_cat_data (cat, > 0); > @@ -279,7 +279,7 @@ > void > __rw_cat_close (int cat) > { > - _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); > + _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data); > > __rw_open_cat_data* const pcat_data = > cat < 0 ? 0 : __rw_manage_cat_data (cat, 0); > > Farid.