From 2c275cf795bb631553ff8dcd60df526b75e46d33 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 27 Sep 2002 15:42:57 +0000 Subject: [PATCH] check for EINTR upon read and write. git-svn-id: https://svn.dealii.org/trunk@6539 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/source/sparse_direct.cc | 31 ++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/deal.II/lac/source/sparse_direct.cc b/deal.II/lac/source/sparse_direct.cc index 0c240be621..67b859704e 100644 --- a/deal.II/lac/source/sparse_direct.cc +++ b/deal.II/lac/source/sparse_direct.cc @@ -21,6 +21,7 @@ #include #include #include +#include // if we know that at least one of the HSL functions are there, @@ -230,9 +231,16 @@ struct SparseDirectMA27::DetachedModeData template void put (const T *t, const size_t N, const char */*debug_info*/) const { - write (server_client_pipe[1], - reinterpret_cast (t), - sizeof(T) * N); + try_write: + int ret = write (server_client_pipe[1], + reinterpret_cast (t), + sizeof(T) * N); + // if read call was + // interrupted, just + // retry + if ((ret<0) && (errno==EINTR)) + goto try_write; + fflush (NULL); }; @@ -242,15 +250,24 @@ struct SparseDirectMA27::DetachedModeData unsigned int count = 0; while (count < sizeof(T)*N) { + try_read: int ret = read (client_server_pipe[0], reinterpret_cast (t) + count, sizeof(T) * N - count); - AssertThrow (ret >= 0, - ExcReadError(ret, errno)); + // if read call was + // interrupted, just + // retry + if ((ret<0) && (errno==EINTR)) + goto try_read; + + // however, if something + // more serious happened, + // then note this! + AssertThrow (ret >= 0, ExcReadError(ret, errno)); + count += ret; }; - }; - + }; }; -- 2.39.5