stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r597265 - /incubator/stdcxx/branches/4.2.x/src/messages.cpp
Date Wed, 21 Nov 2007 23:40:46 GMT
Author: sebor
Date: Wed Nov 21 15:40:43 2007
New Revision: 597265

URL: http://svn.apache.org/viewvc?rev=597265&view=rev
Log:
2007-11-20 Travis Vitek <vitek@roguewave.com>

	STDCXX-607
	* messages.cpp (__rw_cat_close): Put lock guard into local scope
	to avoid recursive acquire on error.

Modified:
    incubator/stdcxx/branches/4.2.x/src/messages.cpp

Modified: incubator/stdcxx/branches/4.2.x/src/messages.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/src/messages.cpp?rev=597265&r1=597264&r2=597265&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/src/messages.cpp (original)
+++ incubator/stdcxx/branches/4.2.x/src/messages.cpp Wed Nov 21 15:40:43 2007
@@ -275,27 +275,37 @@
 // Close a catalog and release its handle.
 void __rw_cat_close (int cat)
 {
-    _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data);
+    bool cat_closed = false;
+
+    {
+        // guard is local to this scope to avoid reacquiring the mutex
+        // if have to generate an exception message string below.
+        _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data);
     
-    __rw_open_cat_data* const pcat_data =
-        cat < 0 ? 0 : __rw_manage_cat_data (cat, 0);
+        __rw_open_cat_data* const pcat_data =
+            cat < 0 ? 0 : __rw_manage_cat_data (cat, 0);
 
-    // 22.2.7.1.2, p5: `catalog' must be valid
-    if (pcat_data && pcat_data->catd != _RWSTD_BAD_CATD) {
+        // 22.2.7.1.2, p5: `catalog' must be valid
+        if (pcat_data && pcat_data->catd != _RWSTD_BAD_CATD) {
 
-	catclose (pcat_data->catd);
+            catclose (pcat_data->catd);
 
-	_STD::locale* const ploc =
-            _RWSTD_REINTERPRET_CAST (_STD::locale*, &pcat_data->loc);
+            _STD::locale* const ploc =
+                _RWSTD_REINTERPRET_CAST (_STD::locale*, &pcat_data->loc);
 
-	ploc->~locale ();
+            ploc->~locale ();
 
-	__rw_manage_cat_data (cat, pcat_data);
-    }
-    else {
-        _RWSTD_REQUIRES (0, (_RWSTD_ERROR_INVALID_ARGUMENT,
-                             _RWSTD_FUNC ("__rw_cat_close (int cat)")));
+            __rw_manage_cat_data (cat, pcat_data);
+
+            cat_closed = true;
+        }
+        else {
+            cat_closed = false;
+        }
     }
+
+    _RWSTD_REQUIRES (cat_closed, (_RWSTD_ERROR_INVALID_ARGUMENT,
+                                  _RWSTD_FUNC ("__rw_cat_close (int cat)")));
 }
 
 



Mime
View raw message