From b9d34efbe7c17d20bc72e3b97f1faa16f7d26170 Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 1 Oct 2002 19:10:30 +0000 Subject: [PATCH] Loop until the specified number of bytes has been written, since write may return early. git-svn-id: https://svn.dealii.org/trunk@6586 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/source/sparse_direct.cc | 32 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/deal.II/lac/source/sparse_direct.cc b/deal.II/lac/source/sparse_direct.cc index 932311b651..26cbfaaa82 100644 --- a/deal.II/lac/source/sparse_direct.cc +++ b/deal.II/lac/source/sparse_direct.cc @@ -360,18 +360,22 @@ struct SparseDirectMA27::DetachedModeData template void put (const T *t, const size_t N, const char *debug_info) const { - // repeat writing until syscall is - // not interrupted - int ret; - do - ret = write (server_client_pipe[1], - reinterpret_cast (t), - sizeof(T) * N); - while ((ret<0) && (errno==EINTR)); - if (ret < 0) - die ("error on client side in 'put'", ret, errno); - if (ret < static_cast(sizeof(T)*N)) - die ("not everything was written", ret, sizeof(T)*N); + unsigned int count = 0; + while (count < sizeof(T)*N) + { + // repeat writing until syscall is + // not interrupted + int ret; + do + ret = write (server_client_pipe[1], + reinterpret_cast (t), + sizeof(T) * N); + while ((ret<0) && (errno==EINTR)); + if (ret < 0) + die ("error on client side in 'put'", ret, errno); + + count += ret; + }; fflush (NULL); CommunicationsLog:: @@ -394,8 +398,8 @@ struct SparseDirectMA27::DetachedModeData if (ret < 0) die ("error on client side in 'get'", ret, errno); - else - count += ret; + + count += ret; }; CommunicationsLog:: -- 2.39.5