From stdcxx-dev-return-5008-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Sat Sep 15 19:09:21 2007 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 55891 invoked from network); 15 Sep 2007 19:09:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Sep 2007 19:09:21 -0000 Received: (qmail 20161 invoked by uid 500); 15 Sep 2007 19:09:14 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 20147 invoked by uid 500); 15 Sep 2007 19:09:14 -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 20136 invoked by uid 99); 15 Sep 2007 19:09:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Sep 2007 12:09:13 -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: domain of msebor@gmail.com designates 209.85.146.178 as permitted sender) Received: from [209.85.146.178] (HELO wa-out-1112.google.com) (209.85.146.178) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Sep 2007 19:09:10 +0000 Received: by wa-out-1112.google.com with SMTP id n4so3642305wag for ; Sat, 15 Sep 2007 12:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=Y4hUZeFgXHnOwJS5Z0uKXuurxGjHEijWbpDRKtFnqSo=; b=FDn9Mx44m+j2ti6uLFcFfOWQyGshkYQ0NsQkvdEu8uey5BQBzjqM6kmvQ2arP0E/IQ98vW7TSz943ItL7EL0f/Fc/GqOcGKKPBf8GdtMKcwiyiPjaR3HCS48ACL+/lBFUiYKU/xKkajZBqpB6hYlbkTeSx/BIqGTaNndi773Et4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=c6S4ziFlE/G5tW7Nt/Lt4h0z+1I2yoX17CNHrw9bjAdXJ25zGuaT1BMMe7QpEpq0JXGZyJwnFH6STSYnCkh5vlXVhbexCh88ssveXneBs+VlBjH01Kcsa6GDj29AhyH5/DCyHSi18pEn3dQ3L2dy3pQ+EANPFYF+HbEW5q55ACM= Received: by 10.114.53.1 with SMTP id b1mr607973waa.1189883328267; Sat, 15 Sep 2007 12:08:48 -0700 (PDT) Received: from ?192.168.1.104? ( [71.229.200.170]) by mx.google.com with ESMTPS id l23sm3169882waf.2007.09.15.12.08.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 15 Sep 2007 12:08:46 -0700 (PDT) Message-ID: <46EC2DB9.5080302@roguewave.com> Date: Sat, 15 Sep 2007 13:08:41 -0600 From: Martin Sebor Organization: Rogue Wave Software User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.12) Gecko/20070719 Fedora/1.0.9-2.fc6 pango-text SeaMonkey/1.0.9 MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: [PATCH] std::messages thread safety References: <7BDB2168BEAEF14C98F1901FD2DE6438F57A7C@epmsa009.minsk.epam.com> <46EACCF5.7010402@roguewave.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Martin Sebor X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: > > Martin Sebor wrote: >> 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. > > Yes, that is the problem. The current static guard prevents multiple > threads from entering the same function simultaneously [i.e. two threads > cannot call __rw_cat_open simultaneously], but it does nothing to > prevent one thread from calling __rw_cat_open() and another thread from > calling __rw_cat_close() at the same time. How come? Aren't all the calls guarded using the same mutex? _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); This provides mutual exclusion across all othe such guards (i.e, those with the same type as an argument). >Since __rw_manage_cat_data > has shared data, access to it must be synchronized using one common > lock. > >> 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. >> > > Yes, but the affected functions are doing more than just calling > catgets() and catopen(). Since they are using shared data, they need to > lock that shared data with a shared mutex. And unless I'm missing something, they are. Martin > >> * 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. >> Martin >