From 1dd3d6f1ac2cebd9befd33484de1d01b715850e6 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 5 Feb 2022 20:39:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=BD=E7=95=A5SIGPIPE=E4=BF=A1=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpBody.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Http/HttpBody.cpp b/src/Http/HttpBody.cpp index 0c1996d1..3103f2d1 100644 --- a/src/Http/HttpBody.cpp +++ b/src/Http/HttpBody.cpp @@ -8,11 +8,13 @@ * may be found in the AUTHORS file in the root of the source tree. */ +#include #include "HttpBody.h" #include "Util/util.h" #include "Util/File.h" #include "Util/uv_errno.h" #include "Util/logger.h" +#include "Util/onceToken.h" #include "HttpClient.h" #ifndef _WIN32 #include @@ -70,6 +72,9 @@ HttpFileBody::HttpFileBody(const std::shared_ptr &fp, size_t offset, size_ #endif int HttpFileBody::sendFile(int fd) { + static onceToken s_token([]() { + signal(SIGPIPE, SIG_IGN); + }); #if defined(__linux__) || defined(__linux) off_t off = _file_offset; return sendfile(fd, fileno(_fp.get()), &off, _max_size);