]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a bug where we were happily using iterators into a list even though this list...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 10 Feb 2007 04:10:00 +0000 (04:10 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 10 Feb 2007 04:10:00 +0000 (04:10 +0000)
git-svn-id: https://svn.dealii.org/trunk@14458 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.html
deal.II/lac/source/sparse_direct.cc

index 4a8dab545fa90a752346a94b2611bd24b5b1be6d..abc8b101b3a44b473e323e43227de3a708a945f2 100644 (file)
@@ -735,6 +735,17 @@ inconvenience this causes.
 <h3>lac</h3>
 
 <ol>
+  <li> <p>Fixed: The <code class="member">SparseDirectMA27</code> class allows
+       to run the sparse direct solver as a separate program (the
+       <code>detached_ma27</code> program) rather than as part of the current
+       program in order to be able to run several instances of it in parallel
+       during multithreaded computations. However, the destructor of the <code
+       class="member">SparseDirectMA27</code> class had a bug that when using
+       this detached mode led to a segmentation fault. This is now fixed.
+       <br>
+       (WB 2007/02/09)
+       </p>
+
   <li> <p>Improved: A simple <code class="member">print_formatted</code> 
        function has been added to <code class="class">SparseMatrixEZ</code>.
        <br>
index 6c773a1dca121920ec878ca8a0f4e6434f56ea46..16eb37e0b64d15d58bd9a24686e14b74d008ccae 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -362,10 +362,24 @@ namespace CommunicationsLog
   void remove_history (const pid_t &child_pid) 
   {
     Threads::ThreadMutex::ScopedLock lock (list_access_lock);
-    for (std::list<Record>::iterator i=communication_log.begin();
-         i!=communication_log.end(); ++i)
-      if (i->child_pid == child_pid)
-        communication_log.erase (i);
+
+                                    // go through the list of records and
+                                    // delete those that correspond to the
+                                    // current pid. note that list::erase
+                                    // invalidates iterators, so we have to
+                                    // re-initialize them each time we move
+                                    // from one to the next
+    unsigned int index=0;
+    while (index < communication_log.size())
+      {
+       std::list<Record>::iterator i = communication_log.begin();
+       std::advance (i, index);
+
+       if (i->child_pid == child_pid)
+         communication_log.erase (i);
+       else
+         ++index;
+      }
   }
 }
 
@@ -548,11 +562,11 @@ SparseDirectMA27::~SparseDirectMA27()
                                          // next close down client
         Threads::ThreadMutex::ScopedLock lock (detached_mode_data->mutex);
         write (detached_mode_data->server_client_pipe[1], "7", 1);
-        
+
                                          // then also delete data
         delete detached_mode_data;
         detached_mode_data = 0;
-      };
+      }
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.