From a220fb3d11f1b5e3a62e4c864a179d233a05bda1 Mon Sep 17 00:00:00 2001 From: Alexandr Gavriliuc Date: Wed, 24 Jul 2019 15:34:35 +0300 Subject: [PATCH] Limit looped continuations in rtSendDocument() --- src/rtRemoteSocketUtils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rtRemoteSocketUtils.cpp b/src/rtRemoteSocketUtils.cpp index c640031..6d8f13d 100644 --- a/src/rtRemoteSocketUtils.cpp +++ b/src/rtRemoteSocketUtils.cpp @@ -396,10 +396,14 @@ rtSendDocument(rapidjson::Document const& doc, int fd, sockaddr_storage const* d flags = MSG_NOSIGNAL; #endif + int limit = 100; while (sendmsg (fd, &msg, flags) < 0) { - if (errno == EINTR) + if ((errno == EINTR) && --limit) + { + rtLogWarn("sending message interrupted, repeating. %d attempts left", limit); continue; + } rtError e = rtErrorFromErrno(errno); rtLogError("failed to send message. %s", rtStrError(e)); return e;