From 748d8018124cb522a2024a5f139f06fef4c27edc Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 13 Nov 2002 22:58:14 +0000 Subject: [PATCH] Retry pthread_create if the error code simply was EAGAIN. git-svn-id: https://svn.dealii.org/trunk@6761 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/source/thread_management.cc | 20 +++++++++++++++++--- deal.II/doc/news/2002/c-3-4.html | 16 +++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/deal.II/base/source/thread_management.cc b/deal.II/base/source/thread_management.cc index 39948f668c..2a75222f8f 100644 --- a/deal.II/base/source/thread_management.cc +++ b/deal.II/base/source/thread_management.cc @@ -18,6 +18,14 @@ # include #endif +#ifndef DEAL_II_USE_DIRECT_ERRNO_H +# include +#else +# include +#endif +#include + + namespace Threads { @@ -227,9 +235,15 @@ namespace Threads tid_list.push_back (pthread_t()); - // start new thread - const int error - = pthread_create (&tid_list.back(), 0, fun_ptr, fun_data); + // start new thread. retry until + // we either succeed or get an + // error other than EAGAIN + int error = 0; + do + { + error = pthread_create (&tid_list.back(), 0, fun_ptr, fun_data); + } + while ( ! ((error == 0) || (error != EAGAIN))); Assert (error == 0, ExcInternalError()); }; diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index eb1b40b48f..2f5332c423 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -180,7 +180,21 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

base

    -
  1. Fixed: The write_text and

    + Changed: In POSIX mode, when the ThreadManager + class created a new thread through pthread_create, + it only checked for the error code and aborted if it was non-zero. Now, it + checks whether the error code is EAGAIN and simply + retries the call if this is the case. This may, in rare cases, lead to a + deadlock or an infinite loop, but will usually just wait until the respective + resources for thread creation are available from the operating system and will + then succeed. +
    + (WB 2002/11/13) +

    + +
  2. + Fixed: The write_text and write_tex functions of the TableHandler class now check whether their ofstream arguments are in a proper state before -- 2.39.5